Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions servant-effectful.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ library
, mtl >=2
, servant-server ^>=0.20
, warp >=3.3
, wai >=3.2.0

test-suite servant-effectful-test
import: common-extensions
Expand Down
10 changes: 6 additions & 4 deletions src/Effectful/Servant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ import Effectful.Dispatch.Static.Primitive (Env, cloneEnv)
import Effectful.Error.Static
import qualified Network.Wai.Handler.Warp as Warp
import Servant hiding ((:>))
import qualified Network.Wai as Wai

-- | Deploy an effectful server.
runWarpServerSettings
:: forall (api :: Type) (es :: [Effect])
. (HasServer api '[], IOE :> es)
=> Warp.Settings
-> ServerT api (Eff (Error ServerError : es))
-> Wai.Middleware
-> Eff es ()
runWarpServerSettings settings =
runWarpServerSettingsContext @api settings EmptyContext
runWarpServerSettings settings = runWarpServerSettingsContext @api settings EmptyContext

-- | Deploy an effectful server with a context.
runWarpServerSettingsContext
Expand All @@ -39,10 +40,11 @@ runWarpServerSettingsContext
=> Warp.Settings
-> Context context
-> ServerT api (Eff (Error ServerError : es))
-> Wai.Middleware
-> Eff es ()
runWarpServerSettingsContext settings ctx server = do
runWarpServerSettingsContext settings context server middleware = do
unsafeEff $ \es -> do
Warp.runSettings settings (serveEff @api es ctx server)
Warp.runSettings settings (middleware (serveEff @api es context server))

-- | Convert an effectful server into a wai application.
serveEff
Expand Down
Loading