Fix all errors
This commit is contained in:
parent
547adabfe3
commit
a90b671607
2 changed files with 16 additions and 13 deletions
|
@ -122,16 +122,15 @@ import Servant.Server.Internal
|
||||||
-- > main :: IO ()
|
-- > main :: IO ()
|
||||||
-- > main = Network.Wai.Handler.Warp.run 8080 app
|
-- > main = Network.Wai.Handler.Warp.run 8080 app
|
||||||
--
|
--
|
||||||
serve :: (HasServer api '[]) => Proxy api -> Server api -> Application
|
|
||||||
serve p = serveWithContext p EmptyContext
|
|
||||||
|
|
||||||
type FullyEvaluateResponse = Bool
|
serve :: (HasServer api '[Bool]) => Proxy api -> Server api -> Application
|
||||||
|
serve p = serveWithContext p (False :. EmptyContext)
|
||||||
|
|
||||||
serveWithContext :: (HasServer api context)
|
serveWithContext :: (HasServer api context)
|
||||||
=> Proxy api -> Context context -> Server api -> Application
|
=> Proxy api -> Context context -> Server api -> Application
|
||||||
serveWithContext p context server =
|
serveWithContext p context server =
|
||||||
toApplication
|
toApplication
|
||||||
False
|
False -- determins if we should fully evaluate response
|
||||||
(runRouter (route p context (emptyDelayed (Route server))))
|
(runRouter (route p context (emptyDelayed (Route server))))
|
||||||
|
|
||||||
-- | Hoist server implementation.
|
-- | Hoist server implementation.
|
||||||
|
|
|
@ -86,11 +86,15 @@ instance MonadThrow m => MonadThrow (RouteResultT m) where
|
||||||
throwM = lift . throwM
|
throwM = lift . throwM
|
||||||
|
|
||||||
toApplication :: Bool -> RoutingApplication -> Application
|
toApplication :: Bool -> RoutingApplication -> Application
|
||||||
toApplication fullyEvaluate ra request respond = ra request routingRespond
|
toApplication fullyEvaluate ra request respond =
|
||||||
|
ra request (maybeEval routingRespond)
|
||||||
where
|
where
|
||||||
maybeEval :: (RouteResult Response -> IO ResponseReceived)
|
maybeEval :: (RouteResult Response -> IO ResponseReceived)
|
||||||
-> RouteResult Response -> IO ResponseReceived
|
-> RouteResult Response -> IO ResponseReceived
|
||||||
maybeEval resp = if fullyEvaluate then force resp else resp
|
maybeEval resp =
|
||||||
|
if fullyEvaluate
|
||||||
|
then force resp
|
||||||
|
else resp
|
||||||
routingRespond :: RouteResult Response -> IO ResponseReceived
|
routingRespond :: RouteResult Response -> IO ResponseReceived
|
||||||
routingRespond (Fail err) = respond $ responseServantErr err
|
routingRespond (Fail err) = respond $ responseServantErr err
|
||||||
routingRespond (FailFatal err) = respond $ responseServantErr err
|
routingRespond (FailFatal err) = respond $ responseServantErr err
|
||||||
|
|
Loading…
Reference in a new issue