Add the guessApproot function (pinging @gregwebs)
This commit is contained in:
parent
e610f3b6f5
commit
5d0a4567f3
@ -38,7 +38,7 @@ $nothing
|
|||||||
|]
|
|]
|
||||||
|
|
||||||
instance Yesod BID where
|
instance Yesod BID where
|
||||||
approot = ApprootStatic "http://localhost:3000"
|
approot = guessApproot
|
||||||
|
|
||||||
instance YesodAuth BID where
|
instance YesodAuth BID where
|
||||||
type AuthId BID = Text
|
type AuthId BID = Text
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
## 1.4.16
|
||||||
|
|
||||||
|
* Add `guessApproot`
|
||||||
|
|
||||||
## 1.4.15
|
## 1.4.15
|
||||||
|
|
||||||
* mkYesod avoids using reify when it isn't necessary. This avoids needing to define the site type below the call to mkYesod.
|
* mkYesod avoids using reify when it isn't necessary. This avoids needing to define the site type below the call to mkYesod.
|
||||||
|
|||||||
@ -71,6 +71,8 @@ module Yesod.Core
|
|||||||
, MonadWidget (..)
|
, MonadWidget (..)
|
||||||
, getRouteToParent
|
, getRouteToParent
|
||||||
, defaultLayoutSub
|
, defaultLayoutSub
|
||||||
|
-- * Approot
|
||||||
|
, guessApproot
|
||||||
-- * Misc
|
-- * Misc
|
||||||
, yesodVersion
|
, yesodVersion
|
||||||
, yesodRender
|
, yesodRender
|
||||||
|
|||||||
@ -56,6 +56,7 @@ import Yesod.Core.Internal.Session
|
|||||||
import Yesod.Core.Widget
|
import Yesod.Core.Widget
|
||||||
import Control.Monad.Trans.Class (lift)
|
import Control.Monad.Trans.Class (lift)
|
||||||
import Data.CaseInsensitive (CI)
|
import Data.CaseInsensitive (CI)
|
||||||
|
import qualified Network.Wai.Request
|
||||||
|
|
||||||
-- | Define settings for a Yesod applications. All methods have intelligent
|
-- | Define settings for a Yesod applications. All methods have intelligent
|
||||||
-- defaults, and therefore no implementation is required.
|
-- defaults, and therefore no implementation is required.
|
||||||
@ -826,3 +827,19 @@ fileLocationToString loc = (loc_package loc) ++ ':' : (loc_module loc) ++
|
|||||||
where
|
where
|
||||||
line = show . fst . loc_start
|
line = show . fst . loc_start
|
||||||
char = show . snd . loc_start
|
char = show . snd . loc_start
|
||||||
|
|
||||||
|
-- | Guess the approot based on request headers. For more information, see
|
||||||
|
-- "Network.Wai.Middleware.Approot"
|
||||||
|
--
|
||||||
|
-- In the case of headers being unavailable, it falls back to 'ApprootRelative'
|
||||||
|
--
|
||||||
|
-- Since 1.4.16
|
||||||
|
guessApproot :: Approot site
|
||||||
|
guessApproot = ApprootRequest $ \_master req ->
|
||||||
|
case W.requestHeaderHost req of
|
||||||
|
Nothing -> ""
|
||||||
|
Just host ->
|
||||||
|
(if Network.Wai.Request.appearsSecure req
|
||||||
|
then "https://"
|
||||||
|
else "http://")
|
||||||
|
`T.append` TE.decodeUtf8With TEE.lenientDecode host
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-core
|
name: yesod-core
|
||||||
version: 1.4.15
|
version: 1.4.16
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
@ -25,7 +25,7 @@ library
|
|||||||
build-depends: base >= 4.3 && < 5
|
build-depends: base >= 4.3 && < 5
|
||||||
, time >= 1.1.4
|
, time >= 1.1.4
|
||||||
, wai >= 3.0
|
, wai >= 3.0
|
||||||
, wai-extra >= 3.0.5
|
, wai-extra >= 3.0.7
|
||||||
, bytestring >= 0.9.1.4
|
, bytestring >= 0.9.1.4
|
||||||
, text >= 0.7
|
, text >= 0.7
|
||||||
, template-haskell
|
, template-haskell
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user