Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not passing a mandatory parameter generates a 500 response, shouldn't it be 400 instead? #84

Open
benjamin-thomas opened this issue Nov 23, 2024 · 0 comments

Comments

@benjamin-thomas
Copy link

Hello! I'm finding your library very interesting, thanks for writing the "mig by example" documentation, it's a pleasure to read!

Given this handler definition

-- http GET localhost:8082/api/auth X-Token:ABC-123
auth :: Header "X-Token" Text -> Get (Resp Text)
auth (Header authToken) =
  pure $
    if authToken == "ABC-123"
      then ok "Access granted"
      else bad unauthorized401 "Invalid token"

I would expect the HTTP clients to receive an HTTP 400 bad request status code, rather than a 500 internal error status code. That's because they made a badly formed request.

image

Appart from making the parameters optional and checking them myself (which I feel would defeat the purpose of the library), can I override this default behavior? Or if my explanation is convincing, could the default behavior be changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant