Created
June 21, 2012 13:46
-
-
Save dpwiz/2965808 to your computer and use it in GitHub Desktop.
Simple app config to use with happstack's ServerPart Response.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Happstack.Server | |
import Control.Monad.Reader | |
import qualified Data.ByteString.Char8 as C | |
myApp :: AppMonad Response | |
myApp = do | |
-- access app config. look mom, no lift! | |
test <- ask | |
-- try some happstack funs. no lift either. | |
rq <- askRq | |
bs <- lookBS "lol" | |
-- test IO please ignore | |
liftIO . print $ test | |
liftIO . print $ rq | |
liftIO . print $ bs | |
-- bye | |
ok $ toResponse ("Oh, hi!" :: C.ByteString) | |
-- Put your stuff here. | |
data AppConfig = AppConfig { appSpam :: C.ByteString | |
, appEggs :: [C.ByteString] } deriving (Eq, Show) | |
config = AppConfig "THIS. IS. SPAAAAAM!!1" [] | |
type AppMonad = ReaderT AppConfig (ServerPartT IO) | |
main = simpleHTTP (nullConf {port=8001}) $ runReaderT myApp config {appEggs=["red", "gold", "green"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment