module Network.Wai.Application.Dynamic (
Config(..),
warpd,
def, nullApp,
) where
import qualified Config.Dyre as Dyre
import Data.Default
import Data.Monoid
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Handler.Warp
data Config
= Config
{ warpSettings :: Settings
, application :: Application
}
instance Default Config where
def = Config
{ warpSettings = defaultSettings
, application = nullApp
}
nullApp :: Application
nullApp _ = return $ ResponseBuilder status404 [] mempty
warpd :: Config -> IO ()
warpd = Dyre.wrapMain $ Dyre.defaultParams
{ Dyre.projectName = "warpd"
, Dyre.realMain = realMain
, Dyre.showError = \_ err -> error err
}
realMain :: Config -> IO ()
realMain Config {..} = do
runSettings warpSettings application