git.iko.soy/typeable/servant
on master help sign in
return 400 (instead of 404) on invalid captures
commit09c40f61e256260773a6e7fc138a589a6ed9d665 authorSönke Hahn <soenkehahn@gmail.com> dateWed 23 Mar 2016, 15:06 (11 years ago) parentb4eef7a
3 files changed+4−4
servant-server/src/Servant/Server/Internal.hs+1−1 servant-server/test/Servant/Server/ErrorSpec.hs+1−1 servant-server/test/Servant/ServerSpec.hs+2−2
servant-server/src/Servant/Server/Internal.hs+1−1
@@ -127,7 +127,7 @@ instance (KnownSymbol capture, FromHttpApiData a, HasServer sublayout context)
127127 route (Proxy :: Proxy sublayout)
128128 context
129129 (addCapture d $ case parseUrlPieceMaybe first :: Maybe a of
130− Nothing -> return $ Fail err404
130+ Nothing -> return $ Fail err400
131131 Just v -> return $ Route v
132132 )
133133
servant-server/test/Servant/Server/ErrorSpec.hs+1−1
@@ -63,7 +63,7 @@ errorOrderSpec =
6363 let badContentType = (hContentType, "text/plain")
6464 badAccept = (hAccept, "text/plain")
6565 badMethod = methodGet
66− badUrl = "home/nonexistent"
66+ badUrl = "nonexistent"
6767 badBody = "nonsense"
6868 badAuth = (hAuthorization, "Basic foofoofoo")
6969 goodContentType = (hContentType, "application/json")
servant-server/test/Servant/ServerSpec.hs+2−2
@@ -202,8 +202,8 @@ captureSpec = do
202202 response <- get "/2"
203203 liftIO $ decode' (simpleBody response) `shouldBe` Just tweety
204204
205− it "returns 404 if the decoding fails" $ do
206− get "/notAnInt" `shouldRespondWith` 404
205+ it "returns 400 if the decoding fails" $ do
206+ get "/notAnInt" `shouldRespondWith` 400
207207
208208 with (return (serve
209209 (Proxy :: Proxy (Capture "captured" String :> Raw))