remove 'forall's from haddock docs
This commit is contained in:
parent
d7587d1df9
commit
a4bb467446
2 changed files with 64 additions and 29 deletions
|
@ -55,63 +55,100 @@ runCI :: CombinatorImplementation combinator arg api context
|
||||||
runCI (CI i) = i
|
runCI (CI i) = i
|
||||||
|
|
||||||
makeCaptureCombinator ::
|
makeCaptureCombinator ::
|
||||||
forall api combinator arg context .
|
|
||||||
(HasServer api context,
|
(HasServer api context,
|
||||||
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler)) =>
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler)) =>
|
||||||
(Context context -> Text -> IO (RouteResult arg))
|
(Context context -> Text -> IO (RouteResult arg))
|
||||||
-> CombinatorImplementation combinator arg api context
|
-> CombinatorImplementation combinator arg api context
|
||||||
makeCaptureCombinator getArg = CI $ \ Proxy context delayed ->
|
makeCaptureCombinator = inner -- we use 'inner' to avoid having 'forall' show up in haddock docs
|
||||||
CaptureRouter $
|
where
|
||||||
route (Proxy :: Proxy api) context $ addCapture delayed $ \ captured ->
|
inner ::
|
||||||
(liftRouteResult =<< liftIO (getArg context captured))
|
forall api combinator arg context .
|
||||||
|
(HasServer api context,
|
||||||
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler)) =>
|
||||||
|
(Context context -> Text -> IO (RouteResult arg))
|
||||||
|
-> CombinatorImplementation combinator arg api context
|
||||||
|
inner getArg = CI $ \ Proxy context delayed ->
|
||||||
|
CaptureRouter $
|
||||||
|
route (Proxy :: Proxy api) context $ addCapture delayed $ \ captured ->
|
||||||
|
(liftRouteResult =<< liftIO (getArg context captured))
|
||||||
|
|
||||||
makeRequestCheckCombinator ::
|
makeRequestCheckCombinator ::
|
||||||
forall api combinator context .
|
|
||||||
(HasServer api context,
|
(HasServer api context,
|
||||||
WithArg () (ServerT api Handler) ~ ServerT api Handler) =>
|
WithArg () (ServerT api Handler) ~ ServerT api Handler) =>
|
||||||
(Context context -> Request -> IO (RouteResult ()))
|
(Context context -> Request -> IO (RouteResult ()))
|
||||||
-> CombinatorImplementation combinator () api context
|
-> CombinatorImplementation combinator () api context
|
||||||
makeRequestCheckCombinator check = CI $ \ Proxy context delayed ->
|
makeRequestCheckCombinator = inner
|
||||||
route (Proxy :: Proxy api) context $ addMethodCheck delayed $
|
where
|
||||||
withRequest $ \ request ->
|
inner ::
|
||||||
liftRouteResult =<< liftIO (check context (protectBody "makeRequestCheckCombinator" request))
|
forall api combinator context .
|
||||||
|
(HasServer api context,
|
||||||
|
WithArg () (ServerT api Handler) ~ ServerT api Handler) =>
|
||||||
|
(Context context -> Request -> IO (RouteResult ()))
|
||||||
|
-> CombinatorImplementation combinator () api context
|
||||||
|
inner check = CI $ \ Proxy context delayed ->
|
||||||
|
route (Proxy :: Proxy api) context $ addMethodCheck delayed $
|
||||||
|
withRequest $ \ request ->
|
||||||
|
liftRouteResult =<< liftIO (check context (protectBody "makeRequestCheckCombinator" request))
|
||||||
|
|
||||||
makeAuthCombinator ::
|
makeAuthCombinator ::
|
||||||
forall api combinator arg context .
|
|
||||||
(HasServer api context,
|
(HasServer api context,
|
||||||
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler)) =>
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler)) =>
|
||||||
(Context context -> Request -> IO (RouteResult arg))
|
(Context context -> Request -> IO (RouteResult arg))
|
||||||
-> CombinatorImplementation combinator arg api context
|
-> CombinatorImplementation combinator arg api context
|
||||||
makeAuthCombinator authCheck = CI $ \ Proxy context delayed ->
|
makeAuthCombinator = inner
|
||||||
route (Proxy :: Proxy api) context $ addAuthCheck delayed $
|
where
|
||||||
withRequest $ \ request ->
|
inner ::
|
||||||
liftRouteResult =<< liftIO (authCheck context (protectBody "makeAuthCombinator" request))
|
forall api combinator arg context .
|
||||||
|
(HasServer api context,
|
||||||
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler)) =>
|
||||||
|
(Context context -> Request -> IO (RouteResult arg))
|
||||||
|
-> CombinatorImplementation combinator arg api context
|
||||||
|
inner authCheck = CI $ \ Proxy context delayed ->
|
||||||
|
route (Proxy :: Proxy api) context $ addAuthCheck delayed $
|
||||||
|
withRequest $ \ request ->
|
||||||
|
liftRouteResult =<< liftIO (authCheck context (protectBody "makeAuthCombinator" request))
|
||||||
|
|
||||||
makeReqBodyCombinator ::
|
makeReqBodyCombinator ::
|
||||||
forall api combinator arg context .
|
|
||||||
(ServerT (combinator :> api) Handler ~ (arg -> ServerT api Handler),
|
(ServerT (combinator :> api) Handler ~ (arg -> ServerT api Handler),
|
||||||
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler),
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler),
|
||||||
HasServer api context) =>
|
HasServer api context) =>
|
||||||
(Context context -> IO ByteString -> arg)
|
(Context context -> IO ByteString -> arg)
|
||||||
-> CombinatorImplementation combinator arg api context
|
-> CombinatorImplementation combinator arg api context
|
||||||
makeReqBodyCombinator getArg = CI $ \ Proxy context delayed ->
|
makeReqBodyCombinator = inner
|
||||||
route (Proxy :: Proxy api) context $ addBodyCheck delayed
|
where
|
||||||
(return ())
|
inner ::
|
||||||
(\ () -> withRequest $ \ request ->
|
forall api combinator arg context .
|
||||||
liftRouteResult $ Route $ getArg context $ requestBody request)
|
(ServerT (combinator :> api) Handler ~ (arg -> ServerT api Handler),
|
||||||
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler),
|
||||||
|
HasServer api context) =>
|
||||||
|
(Context context -> IO ByteString -> arg)
|
||||||
|
-> CombinatorImplementation combinator arg api context
|
||||||
|
inner getArg = CI $ \ Proxy context delayed ->
|
||||||
|
route (Proxy :: Proxy api) context $ addBodyCheck delayed
|
||||||
|
(return ())
|
||||||
|
(\ () -> withRequest $ \ request ->
|
||||||
|
liftRouteResult $ Route $ getArg context $ requestBody request)
|
||||||
|
|
||||||
makeCombinator ::
|
makeCombinator ::
|
||||||
forall api combinator arg context .
|
|
||||||
(ServerT (combinator :> api) Handler ~ (arg -> ServerT api Handler),
|
(ServerT (combinator :> api) Handler ~ (arg -> ServerT api Handler),
|
||||||
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler),
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler),
|
||||||
HasServer api context) =>
|
HasServer api context) =>
|
||||||
(Context context -> Request -> IO (RouteResult arg))
|
(Context context -> Request -> IO (RouteResult arg))
|
||||||
-> CombinatorImplementation combinator arg api context
|
-> CombinatorImplementation combinator arg api context
|
||||||
makeCombinator getArg = CI $ \ Proxy context delayed ->
|
makeCombinator = inner
|
||||||
route (Proxy :: Proxy api) context $ addBodyCheck delayed
|
where
|
||||||
(return ())
|
inner ::
|
||||||
(\ () -> withRequest $ \ request ->
|
forall api combinator arg context .
|
||||||
liftRouteResult =<< liftIO (getArg context (protectBody "makeCombinator" request)))
|
(ServerT (combinator :> api) Handler ~ (arg -> ServerT api Handler),
|
||||||
|
WithArg arg (ServerT api Handler) ~ (arg -> ServerT api Handler),
|
||||||
|
HasServer api context) =>
|
||||||
|
(Context context -> Request -> IO (RouteResult arg))
|
||||||
|
-> CombinatorImplementation combinator arg api context
|
||||||
|
inner getArg = CI $ \ Proxy context delayed ->
|
||||||
|
route (Proxy :: Proxy api) context $ addBodyCheck delayed
|
||||||
|
(return ())
|
||||||
|
(\ () -> withRequest $ \ request ->
|
||||||
|
liftRouteResult =<< liftIO (getArg context (protectBody "makeCombinator" request)))
|
||||||
|
|
||||||
protectBody :: String -> Request -> Request
|
protectBody :: String -> Request -> Request
|
||||||
protectBody name request = request{
|
protectBody name request = request{
|
||||||
|
|
|
@ -255,8 +255,6 @@ instance (HasContextEntry context [(SBS.ByteString, User)], HasServer api contex
|
||||||
type ServerT (AuthWithContext :> api) m = User -> ServerT api m
|
type ServerT (AuthWithContext :> api) m = User -> ServerT api m
|
||||||
route = runCI $ makeAuthCombinator authWithContext
|
route = runCI $ makeAuthCombinator authWithContext
|
||||||
|
|
||||||
-- fixme: remove foralls from haddock
|
|
||||||
|
|
||||||
authWithContext :: (HasContextEntry context [(SBS.ByteString, User)]) =>
|
authWithContext :: (HasContextEntry context [(SBS.ByteString, User)]) =>
|
||||||
Context context -> Request -> IO (RouteResult User)
|
Context context -> Request -> IO (RouteResult User)
|
||||||
authWithContext context request = return $ case lookup "Auth" (requestHeaders request) of
|
authWithContext context request = return $ case lookup "Auth" (requestHeaders request) of
|
||||||
|
|
Loading…
Reference in a new issue