getApprootText
This commit is contained in:
parent
ae04cca639
commit
de3818784a
@ -1,3 +1,7 @@
|
|||||||
|
## 1.4.17
|
||||||
|
|
||||||
|
* Add `getApprootText`
|
||||||
|
|
||||||
## 1.4.16
|
## 1.4.16
|
||||||
|
|
||||||
* Add `guessApproot` and `guessApprootOr`
|
* Add `guessApproot` and `guessApprootOr`
|
||||||
|
|||||||
@ -74,6 +74,7 @@ module Yesod.Core
|
|||||||
-- * Approot
|
-- * Approot
|
||||||
, guessApproot
|
, guessApproot
|
||||||
, guessApprootOr
|
, guessApprootOr
|
||||||
|
, getApprootText
|
||||||
-- * Misc
|
-- * Misc
|
||||||
, yesodVersion
|
, yesodVersion
|
||||||
, yesodRender
|
, yesodRender
|
||||||
|
|||||||
@ -844,13 +844,20 @@ guessApproot = guessApprootOr ApprootRelative
|
|||||||
guessApprootOr :: Approot site -> Approot site
|
guessApprootOr :: Approot site -> Approot site
|
||||||
guessApprootOr fallback = ApprootRequest $ \master req ->
|
guessApprootOr fallback = ApprootRequest $ \master req ->
|
||||||
case W.requestHeaderHost req of
|
case W.requestHeaderHost req of
|
||||||
Nothing -> case fallback of
|
Nothing -> getApprootText fallback master req
|
||||||
ApprootRelative -> ""
|
|
||||||
ApprootStatic t -> t
|
|
||||||
ApprootMaster f -> f master
|
|
||||||
ApprootRequest f -> f master req
|
|
||||||
Just host ->
|
Just host ->
|
||||||
(if Network.Wai.Request.appearsSecure req
|
(if Network.Wai.Request.appearsSecure req
|
||||||
then "https://"
|
then "https://"
|
||||||
else "http://")
|
else "http://")
|
||||||
`T.append` TE.decodeUtf8With TEE.lenientDecode host
|
`T.append` TE.decodeUtf8With TEE.lenientDecode host
|
||||||
|
|
||||||
|
-- | Get the textual application root from an 'Approot' value.
|
||||||
|
--
|
||||||
|
-- Since 1.4.17
|
||||||
|
getApprootText :: Approot site -> site -> W.Request -> Text
|
||||||
|
getApprootText ar site req =
|
||||||
|
case ar of
|
||||||
|
ApprootRelative -> ""
|
||||||
|
ApprootStatic t -> t
|
||||||
|
ApprootMaster f -> f site
|
||||||
|
ApprootRequest f -> f site req
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-core
|
name: yesod-core
|
||||||
version: 1.4.16
|
version: 1.4.17
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user