Repository navigation
T-031: feat(router): add support for the QUERY HTTP method - #159
Open
fleet-panda[bot] wants to merge 3 commits into
Open
fleet-panda[bot] wants to merge 3 commits into
fleet-panda[bot] wants to merge 3 commits into
Conversation
Adds a router.query() shorthand for defining routes that respond to the QUERY HTTP method (draft-ietf-httpbis-safe-method-w-body), along with urlFor.query() and signedUrlFor.query() builders for parity with the other verb-specific helpers. Node.js supports the QUERY method since llhttp shipped it, which is included in every version covered by the engines range (>=24.0.0). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
RFC 10008 (section 2) requires servers to fail QUERY requests when the Content-Type request header is missing, since the request content and its media type together define the query. Section 2.1 recommends a 400 response for requests lacking media type information. The route finder now raises E_INVALID_QUERY_CONTENT_TYPE (400) for a matched QUERY route when the Content-Type header is missing or is not a valid media type. The check runs before the route middleware (including the bodyparser), so the request content is never read, and the error flows through the app error handler like E_ROUTE_NOT_FOUND. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The router only matches routes. The bodyparser reads the Content-Type and the content of a QUERY request, so it makes the check.
Contributor
Author
|
Triage: nothing to do. The only change is commit ae576b7 of the build, which removes the |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #140 by @DavideCarvalho
Goal
QUERY(RFC 10008) is a safe and idempotent HTTP method that carries the query in the request body. #140 addsrouter.query(),urlFor.query()andsignedUrlFor.query(), in the same way as the other methods.The pull request also makes the router fail a
QUERYrequest with no validContent-Type. The bodyparser makes that check (adonisjs/bodyparser#87), because it reads theContent-Typeand the content. The router only matches routes. This pull request removes the check from the router, on top of the commits of the author.Deployment requirements
@adonisjs/http-serveras a minor after the merge. The docs wait for the release.Acceptance criteria
router.query(),urlFor.query()andsignedUrlFor.query()work as feat(router): add support for the QUERY HTTP method #140 gives, with its tests. The tests of the author intests/router/router.spec.ts,tests/router/url_builder.spec.tsandtests/server.spec.tspass.Content-Typeof aQUERYrequest. The new test "invoke router handler for QUERY requests without a Content-Type header" sends aQUERYrequest with noContent-Type. The handler runs, and the status is 200.E_INVALID_QUERY_CONTENT_TYPEis not insrc/errors.ts, androuteFinderdoes not importtype-is.src/server/factories/route_finder.tsis the same as in the first commit of the author.Checks:
npm run lint,npm run typecheckandnpm run quick:test(671 tests) pass.Context changes
None.
Discovered work
None.