From b4eef7acdee7ea3ce86e9ee1be0abb02f3117854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Hahn?= Date: Wed, 23 Mar 2016 14:59:46 +0800 Subject: [PATCH] refactored HasServer Capture instance --- servant-server/src/Servant/Server/Internal.hs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/servant-server/src/Servant/Server/Internal.hs b/servant-server/src/Servant/Server/Internal.hs index c9679d9e..3ae2af6b 100644 --- a/servant-server/src/Servant/Server/Internal.hs +++ b/servant-server/src/Servant/Server/Internal.hs @@ -99,9 +99,6 @@ instance (HasServer a context, HasServer b context) => HasServer (a :<|> b) cont where pa = Proxy :: Proxy a 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, -- this automatically requires your server-side handler to be a function -- 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 -> route (Proxy :: Proxy sublayout) context - (addCapture d $ case captured captureProxy first of + (addCapture d $ case parseUrlPieceMaybe first :: Maybe a of Nothing -> return $ Fail err404 Just v -> return $ Route v ) - where - captureProxy = Proxy :: Proxy (Capture capture a) allowedMethodHead :: Method -> Request -> Bool allowedMethodHead method request = method == methodGet && requestMethod request == methodHead