return 400 (instead of 404) on invalid captures
This commit is contained in:
parent
b4eef7acde
commit
09c40f61e2
3 changed files with 4 additions and 4 deletions
|
@ -127,7 +127,7 @@ instance (KnownSymbol capture, FromHttpApiData a, HasServer sublayout context)
|
|||
route (Proxy :: Proxy sublayout)
|
||||
context
|
||||
(addCapture d $ case parseUrlPieceMaybe first :: Maybe a of
|
||||
Nothing -> return $ Fail err404
|
||||
Nothing -> return $ Fail err400
|
||||
Just v -> return $ Route v
|
||||
)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ errorOrderSpec =
|
|||
let badContentType = (hContentType, "text/plain")
|
||||
badAccept = (hAccept, "text/plain")
|
||||
badMethod = methodGet
|
||||
badUrl = "home/nonexistent"
|
||||
badUrl = "nonexistent"
|
||||
badBody = "nonsense"
|
||||
badAuth = (hAuthorization, "Basic foofoofoo")
|
||||
goodContentType = (hContentType, "application/json")
|
||||
|
|
|
@ -202,8 +202,8 @@ captureSpec = do
|
|||
response <- get "/2"
|
||||
liftIO $ decode' (simpleBody response) `shouldBe` Just tweety
|
||||
|
||||
it "returns 404 if the decoding fails" $ do
|
||||
get "/notAnInt" `shouldRespondWith` 404
|
||||
it "returns 400 if the decoding fails" $ do
|
||||
get "/notAnInt" `shouldRespondWith` 400
|
||||
|
||||
with (return (serve
|
||||
(Proxy :: Proxy (Capture "captured" String :> Raw))
|
||||
|
|
Loading…
Reference in a new issue