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

Cleanup http methods typings #4493

Merged
merged 1 commit into from
Apr 3, 2024
Merged

Conversation

kanongil
Copy link
Contributor

This fixes several issues with the current http method verb handling:

  1. Explicit list all possible verbs for request.route() definitions, including '*'.
  2. Disallow using string for request.route() method, since it made it prone to misspellings.
  3. Only allow lowercased verbs including 'head' for request.method (fixes HTTP_METHODS_PARTIAL_LOWERCASE is missing head #4492).
  4. Only allow lowercased verbs and '*' values for request.route.method.
  5. Allow 'HEAD' and lowercased verbs for request.setMethod().

As with any changes to the typings, this can break the type checks in projects that use hapi. I expect this will mostly just work, but there can be esoteric cases where some work will be required to fix it after updating.

@kanongil kanongil added the types TypeScript type definitions label Mar 21, 2024
@Marsup
Copy link
Contributor

Marsup commented Apr 3, 2024

That's perfect, I'll merge asap. Just rebasing because I think you fixed the failing tests in another PR.

@Marsup Marsup added this to the 21.3.8 milestone Apr 3, 2024
@Marsup Marsup self-assigned this Apr 3, 2024
@Marsup Marsup merged commit 8fb8479 into hapijs:master Apr 3, 2024
15 checks passed
@kanongil kanongil deleted the types-http-methods branch April 9, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types TypeScript type definitions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP_METHODS_PARTIAL_LOWERCASE is missing head
2 participants