Add query() route method for the HTTP QUERY verb (RFC 10008) - #3461
Open
purwantoid wants to merge 2 commits into
Open
Add query() route method for the HTTP QUERY verb (RFC 10008)#3461purwantoid wants to merge 2 commits into
purwantoid wants to merge 2 commits into
Conversation
The HTTP QUERY method was recently published as RFC 10008 on the IETF Standards Track. It is a safe, cacheable method that carries its query in the request body, enabling expressive queries without the URL-length and cacheability trade-offs of GET vs. POST. Support for QUERY is landing across the ecosystem (https://www.rfc-editor.org/rfc/rfc10008), so this adds a query() helper as a sibling of the existing get()/post()/put()/patch()/ delete()/options() route methods on RouteCollectorProxyInter implemented via the existing map() mechanism: ``` $app->query('/search', function (Request $request, Response $response) { $criteria = (string) $request->getBody(); // ...run the query described in the request body... return $response; }); ``` `$app->query()` is equivalent to `$app->map(['QUERY'], ...)` and is not added to any(), so existing any() routes are unaffected.
…owsRuntimeException
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.
Summary
The HTTP
QUERYmethod was recently published as RFC 10008 on the IETF Standards Track. It is a safe, cacheable method that carries its query in the request body, enabling expressive queries without the URL-length and cacheability trade-offs of GET vs. POST. Support forQUERYis landing across the ecosystem, so this adds aquery()helper as a sibling of the existingget()/post()/put()/patch()/delete()/options()route methods.query()toRouteCollectorProxyInterfaceand its implementation inRouteCollectorProxy, equivalent tomap(['QUERY'], $pattern, $callable).any()'s method list, so existingany()routes are unaffected.[Unreleased] / Added.Test plan
vendor/bin/phpunit— full suite passes (437 tests)vendor/bin/phpcs— clean (PSR-12)vendor/bin/phpstan --memory-limit=-1— clean (level max)RouteCollectorProxyTest::testQuery()(unit-level, mirrorstestOptions())AppTest::testQueryRoute()(end-to-end, mirrors the GET/POST/etc. verb test)