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)
|
route (Proxy :: Proxy sublayout)
|
||||||
context
|
context
|
||||||
(addCapture d $ case parseUrlPieceMaybe first :: Maybe a of
|
(addCapture d $ case parseUrlPieceMaybe first :: Maybe a of
|
||||||
Nothing -> return $ Fail err404
|
Nothing -> return $ Fail err400
|
||||||
Just v -> return $ Route v
|
Just v -> return $ Route v
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ errorOrderSpec =
|
||||||
let badContentType = (hContentType, "text/plain")
|
let badContentType = (hContentType, "text/plain")
|
||||||
badAccept = (hAccept, "text/plain")
|
badAccept = (hAccept, "text/plain")
|
||||||
badMethod = methodGet
|
badMethod = methodGet
|
||||||
badUrl = "home/nonexistent"
|
badUrl = "nonexistent"
|
||||||
badBody = "nonsense"
|
badBody = "nonsense"
|
||||||
badAuth = (hAuthorization, "Basic foofoofoo")
|
badAuth = (hAuthorization, "Basic foofoofoo")
|
||||||
goodContentType = (hContentType, "application/json")
|
goodContentType = (hContentType, "application/json")
|
||||||
|
|
|
@ -202,8 +202,8 @@ captureSpec = do
|
||||||
response <- get "/2"
|
response <- get "/2"
|
||||||
liftIO $ decode' (simpleBody response) `shouldBe` Just tweety
|
liftIO $ decode' (simpleBody response) `shouldBe` Just tweety
|
||||||
|
|
||||||
it "returns 404 if the decoding fails" $ do
|
it "returns 400 if the decoding fails" $ do
|
||||||
get "/notAnInt" `shouldRespondWith` 404
|
get "/notAnInt" `shouldRespondWith` 400
|
||||||
|
|
||||||
with (return (serve
|
with (return (serve
|
||||||
(Proxy :: Proxy (Capture "captured" String :> Raw))
|
(Proxy :: Proxy (Capture "captured" String :> Raw))
|
||||||
|
|
Loading…
Reference in a new issue