wrapped everything in the EnvM Monad, the logging might commence
This commit is contained in:
parent
27a51c2121
commit
ac303abcc0
7 changed files with 78 additions and 51 deletions
|
@ -3,9 +3,8 @@
|
|||
module Backend.Http
|
||||
where
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HTTP_SUPPORT
|
||||
#else
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
-- we export a bit more than we have to, because the https module can reuse these things.
|
||||
|
@ -32,6 +31,8 @@ import qualified Toml
|
|||
import Data.Semigroup (getFirst, First(..))
|
||||
import Data.Maybe(fromJust)
|
||||
import Data.Coerce
|
||||
import Environment
|
||||
import Control.Monad.IO.Class
|
||||
|
||||
type BindPreference = String
|
||||
|
||||
|
@ -73,8 +74,8 @@ httpConfigCodec =
|
|||
httpConfigsCodec :: TomlCodec [HttpConfiguration]
|
||||
httpConfigsCodec = Toml.list httpConfigCodec "http"
|
||||
|
||||
forkHttpBackend :: Wai.Application -> FilePath -> IO [MVar ()]
|
||||
forkHttpBackend app configFile = forkWithConfigs (backend app) httpConfigsCodec configFile
|
||||
forkHttpBackend :: Wai.Application -> FilePath -> EnvM [MVar ()]
|
||||
forkHttpBackend app = forkWithConfigs (backend app) httpConfigsCodec
|
||||
|
||||
httpToWarpConfig :: HttpConfiguration -> HTTP.Settings
|
||||
httpToWarpConfig config' = HTTP.setPort confPort $ HTTP.setHost (fromString confBindPref) HTTP.defaultSettings
|
||||
|
@ -84,6 +85,6 @@ httpToWarpConfig config' = HTTP.setPort confPort $ HTTP.setHost (fromString conf
|
|||
confBindPref = getConfigM $ bindPref config
|
||||
|
||||
|
||||
backend :: Wai.Application -> HttpConfiguration -> IO ()
|
||||
backend app config = HTTP.runSettings (httpToWarpConfig config) app
|
||||
backend :: Wai.Application -> HttpConfiguration -> EnvM ()
|
||||
backend app config = liftIO $ HTTP.runSettings (httpToWarpConfig config) app
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue