Skip to content

Commit 3d9a151

Browse files
author
Sasa Bogicevic
committed
Add helper functions
1 parent 4d46e98 commit 3d9a151

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

servant-server/src/Servant/Server.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module Servant.Server
1010
( -- * Run a wai application from an API
1111
serve
1212
, serveWithContext
13+
, fullyEvalResponse
14+
, noEvalResponse
1315

1416
, -- * Construct a wai Application from an API
1517
toApplication
@@ -124,16 +126,23 @@ import Servant.Server.Internal
124126
--
125127

126128
serve :: (HasServer api '[Bool]) => Proxy api -> Server api -> Application
127-
serve p = serveWithContext p (False :. EmptyContext)
129+
serve p = serveWithContext p noEvalResponse
128130

129131
serveWithContext :: (HasServer api context, HasContextEntry context Bool)
130132
=> Proxy api -> Context context -> Server api -> Application
131133
serveWithContext p context server =
132134
toApplication
133-
(getContextEntry context :: Bool)
135+
((getContextEntry context :: Bool) || False)
134136
-- ^ determins if we should fully evaluate response
137+
-- defaults to False
135138
(runRouter (route p context (emptyDelayed (Route server))))
136139

140+
fullyEvalResponse :: Context '[Bool]
141+
fullyEvalResponse = True :. EmptyContext
142+
143+
noEvalResponse :: Context '[Bool]
144+
noEvalResponse = False :. EmptyContext
145+
137146
-- | Hoist server implementation.
138147
--
139148
-- Sometimes our cherished `Handler` monad isn't quite the type you'd like for

0 commit comments

Comments
 (0)