{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Servant.Server.Internal.Delayed where
import Control.Monad.IO.Class
(MonadIO (..))
import Control.Monad.Reader
(ask)
import Control.Monad.Trans.Resource
(ResourceT, runResourceT)
import Network.Wai
(Request, Response)
import Servant.Server.Internal.DelayedIO
import Servant.Server.Internal.Handler
import Servant.Server.Internal.RouteResult
import Servant.Server.Internal.ServerError
data Delayed env c where
Delayed :: { ()
capturesD :: env -> DelayedIO captures
, forall env c. Delayed env c -> DelayedIO ()
methodD :: DelayedIO ()
, ()
authD :: DelayedIO auth
, forall env c. Delayed env c -> DelayedIO ()
acceptD :: DelayedIO ()
, ()
contentD :: DelayedIO contentType
, ()
paramsD :: DelayedIO params
, :: DelayedIO headers
, ()
bodyD :: contentType -> DelayedIO body
, ()
serverD :: captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult c
} -> Delayed env c
instance Functor (Delayed env) where
fmap :: forall a b. (a -> b) -> Delayed env a -> Delayed env b
fmap a -> b
f Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
contentType -> DelayedIO body
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} =
Delayed
{ serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult b
serverD = \ captures
c params
p headers
h auth
a body
b Request
req -> a -> b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
serverD captures
c params
p headers
h auth
a body
b Request
req
, DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
contentType -> DelayedIO body
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
..
}
emptyDelayed :: RouteResult a -> Delayed env a
emptyDelayed :: forall a env. RouteResult a -> Delayed env a
emptyDelayed RouteResult a
result =
forall env captures auth contentType params headers body c.
(env -> DelayedIO captures)
-> DelayedIO ()
-> DelayedIO auth
-> DelayedIO ()
-> DelayedIO contentType
-> DelayedIO params
-> DelayedIO headers
-> (contentType -> DelayedIO body)
-> (captures
-> params -> headers -> auth -> body -> Request -> RouteResult c)
-> Delayed env c
Delayed (forall a b. a -> b -> a
const DelayedIO ()
r) DelayedIO ()
r DelayedIO ()
r DelayedIO ()
r DelayedIO ()
r DelayedIO ()
r DelayedIO ()
r (forall a b. a -> b -> a
const DelayedIO ()
r) (\ ()
_ ()
_ ()
_ ()
_ ()
_ Request
_ -> RouteResult a
result)
where
r :: DelayedIO ()
r = forall (m :: * -> *) a. Monad m => a -> m a
return ()
addCapture :: Delayed env (a -> b)
-> (captured -> DelayedIO a)
-> Delayed (captured, env) b
addCapture :: forall env a b captured.
Delayed env (a -> b)
-> (captured -> DelayedIO a) -> Delayed (captured, env) b
addCapture Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
contentType -> DelayedIO body
serverD :: captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} captured -> DelayedIO a
new =
Delayed
{ capturesD :: (captured, env) -> DelayedIO (captures, a)
capturesD = \ (captured
txt, env
env) -> (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> env -> DelayedIO captures
capturesD env
env forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> captured -> DelayedIO a
new captured
txt
, serverD :: (captures, a)
-> params -> headers -> auth -> body -> Request -> RouteResult b
serverD = \ (captures
x, a
v) params
p headers
h auth
a body
b Request
req -> (forall a b. (a -> b) -> a -> b
$ a
v) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
serverD captures
x params
p headers
h auth
a body
b Request
req
, DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
contentType -> DelayedIO body
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
..
}
addParameterCheck :: Delayed env (a -> b)
-> DelayedIO a
-> Delayed env b
addParameterCheck :: forall env a b.
Delayed env (a -> b) -> DelayedIO a -> Delayed env b
addParameterCheck Delayed {DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
contentType -> DelayedIO body
serverD :: captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} DelayedIO a
new =
Delayed
{ paramsD :: DelayedIO (params, a)
paramsD = (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DelayedIO params
paramsD forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DelayedIO a
new
, serverD :: captures
-> (params, a)
-> headers
-> auth
-> body
-> Request
-> RouteResult b
serverD = \captures
c (params
p, a
pNew) headers
h auth
a body
b Request
req -> (forall a b. (a -> b) -> a -> b
$ a
pNew) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
serverD captures
c params
p headers
h auth
a body
b Request
req
, DelayedIO auth
DelayedIO contentType
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
contentType -> DelayedIO body
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
..
}
addHeaderCheck :: Delayed env (a -> b)
-> DelayedIO a
-> Delayed env b
Delayed {DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
contentType -> DelayedIO body
serverD :: captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} DelayedIO a
new =
Delayed
{ headersD :: DelayedIO (headers, a)
headersD = (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DelayedIO headers
headersD forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DelayedIO a
new
, serverD :: captures
-> params
-> (headers, a)
-> auth
-> body
-> Request
-> RouteResult b
serverD = \captures
c params
p (headers
h, a
hNew) auth
a body
b Request
req -> (forall a b. (a -> b) -> a -> b
$ a
hNew) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
serverD captures
c params
p headers
h auth
a body
b Request
req
, DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO ()
env -> DelayedIO captures
contentType -> DelayedIO body
bodyD :: contentType -> DelayedIO body
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
bodyD :: contentType -> DelayedIO body
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
..
}
addMethodCheck :: Delayed env a
-> DelayedIO ()
-> Delayed env a
addMethodCheck :: forall env a. Delayed env a -> DelayedIO () -> Delayed env a
addMethodCheck Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
contentType -> DelayedIO body
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} DelayedIO ()
new =
Delayed
{ methodD :: DelayedIO ()
methodD = DelayedIO ()
methodD forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* DelayedIO ()
new
, DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
contentType -> DelayedIO body
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
capturesD :: env -> DelayedIO captures
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
capturesD :: env -> DelayedIO captures
..
}
addAuthCheck :: Delayed env (a -> b)
-> DelayedIO a
-> Delayed env b
addAuthCheck :: forall env a b.
Delayed env (a -> b) -> DelayedIO a -> Delayed env b
addAuthCheck Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
contentType -> DelayedIO body
serverD :: captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} DelayedIO a
new =
Delayed
{ authD :: DelayedIO (auth, a)
authD = (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DelayedIO auth
authD forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DelayedIO a
new
, serverD :: captures
-> params
-> headers
-> (auth, a)
-> body
-> Request
-> RouteResult b
serverD = \ captures
c params
p headers
h (auth
y, a
v) body
b Request
req -> (forall a b. (a -> b) -> a -> b
$ a
v) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
serverD captures
c params
p headers
h auth
y body
b Request
req
, DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
contentType -> DelayedIO body
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
..
}
addBodyCheck :: Delayed env (a -> b)
-> DelayedIO c
-> (c -> DelayedIO a)
-> Delayed env b
addBodyCheck :: forall env a b c.
Delayed env (a -> b)
-> DelayedIO c -> (c -> DelayedIO a) -> Delayed env b
addBodyCheck Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
contentType -> DelayedIO body
serverD :: captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} DelayedIO c
newContentD c -> DelayedIO a
newBodyD =
Delayed
{ contentD :: DelayedIO (contentType, c)
contentD = (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DelayedIO contentType
contentD forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DelayedIO c
newContentD
, bodyD :: (contentType, c) -> DelayedIO (body, a)
bodyD = \(contentType
content, c
c) -> (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> contentType -> DelayedIO body
bodyD contentType
content forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> c -> DelayedIO a
newBodyD c
c
, serverD :: captures
-> params
-> headers
-> auth
-> (body, a)
-> Request
-> RouteResult b
serverD = \ captures
c params
p headers
h auth
a (body
z, a
v) Request
req -> (forall a b. (a -> b) -> a -> b
$ a
v) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
serverD captures
c params
p headers
h auth
a body
z Request
req
, DelayedIO auth
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
headersD :: DelayedIO headers
paramsD :: DelayedIO params
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
headersD :: DelayedIO headers
paramsD :: DelayedIO params
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
..
}
addAcceptCheck :: Delayed env a
-> DelayedIO ()
-> Delayed env a
addAcceptCheck :: forall env a. Delayed env a -> DelayedIO () -> Delayed env a
addAcceptCheck Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
contentType -> DelayedIO body
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} DelayedIO ()
new =
Delayed
{ acceptD :: DelayedIO ()
acceptD = DelayedIO ()
acceptD forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> DelayedIO ()
new
, DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
contentType -> DelayedIO body
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
..
}
passToServer :: Delayed env (a -> b) -> (Request -> a) -> Delayed env b
passToServer :: forall env a b.
Delayed env (a -> b) -> (Request -> a) -> Delayed env b
passToServer Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
contentType -> DelayedIO body
serverD :: captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} Request -> a
x =
Delayed
{ serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult b
serverD = \ captures
c params
p headers
h auth
a body
b Request
req -> (forall a b. (a -> b) -> a -> b
$ Request -> a
x Request
req) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> captures
-> params
-> headers
-> auth
-> body
-> Request
-> RouteResult (a -> b)
serverD captures
c params
p headers
h auth
a body
b Request
req
, DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
contentType -> DelayedIO body
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
..
}
runDelayed :: Delayed env a
-> env
-> Request
-> ResourceT IO (RouteResult a)
runDelayed :: forall env a.
Delayed env a -> env -> Request -> ResourceT IO (RouteResult a)
runDelayed Delayed{DelayedIO auth
DelayedIO contentType
DelayedIO params
DelayedIO headers
DelayedIO ()
env -> DelayedIO captures
captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
contentType -> DelayedIO body
serverD :: captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
bodyD :: contentType -> DelayedIO body
headersD :: DelayedIO headers
paramsD :: DelayedIO params
contentD :: DelayedIO contentType
acceptD :: DelayedIO ()
authD :: DelayedIO auth
methodD :: DelayedIO ()
capturesD :: env -> DelayedIO captures
serverD :: ()
bodyD :: ()
headersD :: ()
paramsD :: ()
contentD :: ()
acceptD :: forall env c. Delayed env c -> DelayedIO ()
authD :: ()
methodD :: forall env c. Delayed env c -> DelayedIO ()
capturesD :: ()
..} env
env = forall a. DelayedIO a -> Request -> ResourceT IO (RouteResult a)
runDelayedIO forall a b. (a -> b) -> a -> b
$ do
Request
r <- forall r (m :: * -> *). MonadReader r m => m r
ask
captures
c <- env -> DelayedIO captures
capturesD env
env
DelayedIO ()
methodD
auth
a <- DelayedIO auth
authD
DelayedIO ()
acceptD
contentType
content <- DelayedIO contentType
contentD
params
p <- DelayedIO params
paramsD
headers
h <- DelayedIO headers
headersD
body
b <- contentType -> DelayedIO body
bodyD contentType
content
forall a. RouteResult a -> DelayedIO a
liftRouteResult (captures
-> params -> headers -> auth -> body -> Request -> RouteResult a
serverD captures
c params
p headers
h auth
a body
b Request
r)
runAction :: Delayed env (Handler a)
-> env
-> Request
-> (RouteResult Response -> IO r)
-> (a -> RouteResult Response)
-> IO r
runAction :: forall env a r.
Delayed env (Handler a)
-> env
-> Request
-> (RouteResult Response -> IO r)
-> (a -> RouteResult Response)
-> IO r
runAction Delayed env (Handler a)
action env
env Request
req RouteResult Response -> IO r
respond a -> RouteResult Response
k = forall (m :: * -> *) a. MonadUnliftIO m => ResourceT m a -> m a
runResourceT forall a b. (a -> b) -> a -> b
$
forall env a.
Delayed env a -> env -> Request -> ResourceT IO (RouteResult a)
runDelayed Delayed env (Handler a)
action env
env Request
req forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= RouteResult (Handler a) -> ResourceT IO (RouteResult Response)
go forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. RouteResult Response -> IO r
respond
where
go :: RouteResult (Handler a) -> ResourceT IO (RouteResult Response)
go (Fail ServerError
e) = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. ServerError -> RouteResult a
Fail ServerError
e
go (FailFatal ServerError
e) = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. ServerError -> RouteResult a
FailFatal ServerError
e
go (Route Handler a
a) = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Either ServerError a
e <- forall a. Handler a -> IO (Either ServerError a)
runHandler Handler a
a
case Either ServerError a
e of
Left ServerError
err -> forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> RouteResult a
Route forall a b. (a -> b) -> a -> b
$ ServerError -> Response
responseServerError ServerError
err
Right a
x -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! a -> RouteResult Response
k a
x