refactored HasServer Capture instance
This commit is contained in:
parent
509d8ab605
commit
b4eef7acde
1 changed files with 1 additions and 6 deletions
|
@ -99,9 +99,6 @@ instance (HasServer a context, HasServer b context) => HasServer (a :<|> b) cont
|
||||||
where pa = Proxy :: Proxy a
|
where pa = Proxy :: Proxy a
|
||||||
pb = Proxy :: Proxy b
|
pb = Proxy :: Proxy b
|
||||||
|
|
||||||
captured :: FromHttpApiData a => proxy (Capture sym a) -> Text -> Maybe a
|
|
||||||
captured _ = parseUrlPieceMaybe
|
|
||||||
|
|
||||||
-- | If you use 'Capture' in one of the endpoints for your API,
|
-- | If you use 'Capture' in one of the endpoints for your API,
|
||||||
-- this automatically requires your server-side handler to be a function
|
-- this automatically requires your server-side handler to be a function
|
||||||
-- that takes an argument of the type specified by the 'Capture'.
|
-- that takes an argument of the type specified by the 'Capture'.
|
||||||
|
@ -129,12 +126,10 @@ instance (KnownSymbol capture, FromHttpApiData a, HasServer sublayout context)
|
||||||
DynamicRouter $ \ first ->
|
DynamicRouter $ \ first ->
|
||||||
route (Proxy :: Proxy sublayout)
|
route (Proxy :: Proxy sublayout)
|
||||||
context
|
context
|
||||||
(addCapture d $ case captured captureProxy first of
|
(addCapture d $ case parseUrlPieceMaybe first :: Maybe a of
|
||||||
Nothing -> return $ Fail err404
|
Nothing -> return $ Fail err404
|
||||||
Just v -> return $ Route v
|
Just v -> return $ Route v
|
||||||
)
|
)
|
||||||
where
|
|
||||||
captureProxy = Proxy :: Proxy (Capture capture a)
|
|
||||||
|
|
||||||
allowedMethodHead :: Method -> Request -> Bool
|
allowedMethodHead :: Method -> Request -> Bool
|
||||||
allowedMethodHead method request = method == methodGet && requestMethod request == methodHead
|
allowedMethodHead method request = method == methodGet && requestMethod request == methodHead
|
||||||
|
|
Loading…
Reference in a new issue