44 lines
1.4 KiB
Plaintext
44 lines
1.4 KiB
Plaintext
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
module Application
|
|
( with~sitearg~
|
|
, withDevelAppPort
|
|
) where
|
|
|
|
import Import
|
|
import Settings (loadExtra)
|
|
import Settings.StaticFiles (staticSite)
|
|
import Yesod.Default.Config
|
|
import Yesod.Default.Main (defaultDevelAppWith, defaultRunner)
|
|
import Yesod.Default.Handlers (getFaviconR, getRobotsR)
|
|
import Yesod.Logger (Logger)
|
|
import Network.Wai (Application)
|
|
import Data.Dynamic (Dynamic, toDyn)
|
|
|
|
-- Import all relevant handler modules here.
|
|
import Handler.Root
|
|
|
|
-- This line actually creates our YesodSite instance. It is the second half
|
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see
|
|
-- the comments there for more details.
|
|
mkYesodDispatch "~sitearg~" resources~sitearg~
|
|
|
|
-- This function allocates resources (such as a database connection pool),
|
|
-- performs initialization and creates a WAI application. This is also the
|
|
-- place to put your migrate statements to have automatic database
|
|
-- migrations handled by Yesod.
|
|
with~sitearg~ :: AppConfig DefaultEnv Extra -> Logger -> (Application -> IO ()) -> IO ()
|
|
with~sitearg~ conf logger f = do
|
|
s <- staticSite
|
|
let h = ~sitearg~ conf logger s
|
|
defaultRunner f h
|
|
|
|
-- for yesod devel
|
|
withDevelAppPort :: Dynamic
|
|
withDevelAppPort =
|
|
toDyn $ defaultDevelAppWith loader with~sitearg~
|
|
where
|
|
loader = loadConfig (configSettings Development)
|
|
{ csLoadExtra = loadExtra
|
|
}
|
|
|