multidomain capability
This commit is contained in:
parent
425a815435
commit
d08b9d8aee
2 changed files with 17 additions and 1 deletions
|
@ -8,6 +8,9 @@ import Yesod.Auth.BrowserId (authBrowserId)
|
||||||
import Yesod.Default.Util (addStaticContentExternal)
|
import Yesod.Default.Util (addStaticContentExternal)
|
||||||
import Yesod.Core.Types (Logger)
|
import Yesod.Core.Types (Logger)
|
||||||
import Settings.StaticFiles
|
import Settings.StaticFiles
|
||||||
|
--snip
|
||||||
|
import qualified Data.Text as T
|
||||||
|
import Network.Wai as Wai
|
||||||
|
|
||||||
-- | The foundation datatype for your application. This can be a good place to
|
-- | The foundation datatype for your application. This can be a good place to
|
||||||
-- keep settings and values requiring initialization before your application
|
-- keep settings and values requiring initialization before your application
|
||||||
|
@ -36,12 +39,24 @@ mkYesodData "App" $(parseRoutesFile "config/routes")
|
||||||
-- | A convenient synonym for creating forms.
|
-- | A convenient synonym for creating forms.
|
||||||
type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)
|
type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)
|
||||||
|
|
||||||
|
approotRequest :: App -> Wai.Request -> T.Text
|
||||||
|
approotRequest master req =
|
||||||
|
case requestHeaderHost req of
|
||||||
|
Just a -> prefix `T.append` decodeUtf8 a
|
||||||
|
Nothing -> appRoot $ appSettings master
|
||||||
|
where
|
||||||
|
prefix =
|
||||||
|
case isSecure req of
|
||||||
|
True -> "https://"
|
||||||
|
False -> "http://"
|
||||||
|
|
||||||
-- Please see the documentation for the Yesod typeclass. There are a number
|
-- Please see the documentation for the Yesod typeclass. There are a number
|
||||||
-- of settings which can be configured by overriding methods here.
|
-- of settings which can be configured by overriding methods here.
|
||||||
instance Yesod App where
|
instance Yesod App where
|
||||||
-- Controls the base of generated URLs. For more information on modifying,
|
-- Controls the base of generated URLs. For more information on modifying,
|
||||||
-- see: https://github.com/yesodweb/yesod/wiki/Overriding-approot
|
-- see: https://github.com/yesodweb/yesod/wiki/Overriding-approot
|
||||||
approot = ApprootMaster $ appRoot . appSettings
|
--approot = ApprootMaster $ appRoot . appSettings
|
||||||
|
approot = ApprootRequest approotRequest
|
||||||
|
|
||||||
-- Store session data on the client in encrypted cookies,
|
-- Store session data on the client in encrypted cookies,
|
||||||
-- default session idle timeout is 120 minutes
|
-- default session idle timeout is 120 minutes
|
||||||
|
|
|
@ -91,6 +91,7 @@ library
|
||||||
-- snip
|
-- snip
|
||||||
, mime-mail
|
, mime-mail
|
||||||
, blaze-markup
|
, blaze-markup
|
||||||
|
, wai
|
||||||
|
|
||||||
executable yammat
|
executable yammat
|
||||||
if flag(library-only)
|
if flag(library-only)
|
||||||
|
|
Loading…
Reference in a new issue