feat: support the HTTP QUERY method (RFC 10008) - #159
Conversation
QUERY is a safe, idempotent request method that carries the query in the request content instead of the URI. Add it to the method bitmask table so routes can match on it, and correct the README method list, which was also missing PURGE.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe documented route methods now include ChangesHTTP method support
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@shreemaan-abhishek sorry for the direct ping. You merged the last few changes here (150, 151, 152), so you seemed like the right person to ask. Could you take a look at this one when you have time? It adds Two follow-up questions:
Happy to rebase or split this differently if you prefer. |
There was a problem hiding this comment.
Pull request overview
Adds RFC 10008 QUERY method support to method-restricted routes.
Changes:
- Adds
QUERYto the method bitmask. - Tests matching behavior.
- Documents
PURGEandQUERY.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/resty/radixtree.lua |
Registers the QUERY method bitmask. |
t/sanity.t |
Tests QUERY route matching and rejection cases. |
README.md |
Updates supported method documentation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
What
Adds
QUERYto theMETHODSbitmask table so routes can match on it.RFC 10008 (Proposed Standard) defines
QUERYas a safe and idempotent request method that carries the query in the request content instead of the URI. It is intended for queries that do not fit a URI well — large filter expressions, or ones containing values that should not land in access logs, browser history orRefererheaders — while keepingGET's semantics (cacheable, transparently retryable), which the usualPOST-based workaround gives up.Today the method cannot be routed:
rx:match("/aa", {method = "QUERY"})never matches a route that restricts methods, becauseMETHODS["QUERY"]isniland the type check atradixtree.lua:721fails.radix.new{{paths = {"/aa"}, methods = {"QUERY"}}}errors atradixtree.lua:425—bit.boron anilbitmask.Routes that omit
methodsalready match any method token, so this only affects method-restricted routes.QUERYis appended to the end of the list, so the bitmask values of existing methods are unchanged.This is the same shape of change as #115, which added
PURGE(released in v2.8.2).Tests
t/sanity.tTEST 11 mirrors the existingPURGEtest (TEST 10): a route restricted toQUERYmatches aQUERYrequest and nothing else. The followingIteratortest is renumbered 11 → 12.Drive-by doc fix
The
methodsrow in README's route-options table listed valid values asGET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, CONNECT, TRACE— it never picked upPURGE. Updated to match the code, includingQUERY.Downstream note
Apache APISIX validates route
methodsagainst the same list inapisix/schema_def.lua, so addingQUERYthere depends on a release containing this change (its rockspec pinslua-resty-radixtree). Happy to follow up on the APISIX side once this lands.Summary by CodeRabbit
QUERYHTTP method in route matching.QUERYrequests from other methods, including nested paths.PURGEandQUERYamong the valid HTTP methods for routes.QUERYmatching behavior and preventing unintended matches for other methods or paths.