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

HEAD WAI requests should match GET path entries in the API #19

Open
fiadliel opened this issue Aug 1, 2020 · 0 comments
Open

HEAD WAI requests should match GET path entries in the API #19

fiadliel opened this issue Aug 1, 2020 · 0 comments

Comments

@fiadliel
Copy link

fiadliel commented Aug 1, 2020

Servant responds to HEAD requests with the result of the GET path (minus the body), since haskell-servant/servant@050aa21

If the WAI verb is HEAD, and the path verb is GET, this path should match.

e.g.

instance ReflectMethod method => HasEndpoint (Verb method status cts a) where
    getEndpoint _ req =
      if requestMethod req == method || (requestMethod req == methodHead && method == methodGet) then
        Just (APIEndpoint [] method)
      else
        Nothing

    enumerateEndpoints _ = [APIEndpoint mempty method]
      where method = reflectMethod (Proxy :: Proxy method)

Though actually, this is incomplete; a GET route should also register a HEAD route in enumerateEndpoints, and the WAI verb should be used in preference to the route verb in the result of getEndpoint.

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