module Dingo.Server
(
DingoSettings
, defaultDingoSettings
, dsPort
, dsResourceBundles
, runApplication
) where
import Data.Text (Text)
import Dingo.Internal.Application (Application)
import Dingo.Internal.Callback (CallbackM)
import Dingo.Internal.Server.State (emptyServerState)
import Dingo.Internal.Server.Wai (mkWaiApplication)
import Dingo.ResourceBundle (ResourceBundle)
import Network.Wai.Handler.Warp (runSettings, defaultSettings, Settings(..))
data DingoSettings =
DingoSettings { dsPort :: Int
, dsResourceBundles :: [ResourceBundle]
}
defaultDingoSettings :: DingoSettings
defaultDingoSettings = DingoSettings 3000 []
runApplication :: DingoSettings -> Text -> (Application -> CallbackM ()) ->IO ()
runApplication dingoSettings applicationTitle application = do
serverState <- emptyServerState application applicationTitle $ dsResourceBundles dingoSettings
runSettings settings $ mkWaiApplication serverState
where
settings =
defaultSettings { settingsTimeout = 60
, settingsPort = dsPort dingoSettings
}