Skip to content

🔥 feat: Add HTTP QUERY method support (RFC 10008)#4436

Open
nekoworks-magic wants to merge 5 commits into
gofiber:mainfrom
neko-sc:feat/http-query-method
Open

🔥 feat: Add HTTP QUERY method support (RFC 10008)#4436
nekoworks-magic wants to merge 5 commits into
gofiber:mainfrom
neko-sc:feat/http-query-method

Conversation

@nekoworks-magic

Copy link
Copy Markdown

Description

Add first-class support for the HTTP QUERY method (RFC 10008). QUERY is safe and idempotent like GET, but allows request bodies for complex queries.

Changes introduced

  • MethodQuery constant, methodQuery iota, DefaultMethods entry
  • Query() on Router, Register interfaces and all implementations (App, Group, Registering, domainRouter, domainRegistering)
  • Request.Query() client shorthand
  • IsMethodSafe returns true for QUERY
  • CSRF safe-method branch includes QUERY
  • CORS default AllowMethods includes QUERY
  • Logger color: shares Cyan with GET

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Updated the documentation in the /docs/ directory for Fiber's documentation.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • Aimed for optimal performance with minimal allocations in the new code.

Register QUERY as a first-class HTTP method alongside the existing nine.
QUERY is safe and idempotent, allowing request bodies for complex queries
without the URL-length constraints of GET.

- Add MethodQuery constant and methodQuery iota
- Add Query() to Router, Register interfaces and all implementations
  (App, Group, Registering, domainRouter, domainRegistering)
- Add Query() client shorthand on Request
- Mark QUERY as safe in IsMethodSafe (idempotent follows from safe)
- Include QUERY in CSRF safe-method branch (no token required)
- Include QUERY in CORS default AllowMethods
- Add QUERY color to logger middleware
- Update constants documentation
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 67fa1a96-648e-496b-8443-4269f0150c0d

📥 Commits

Reviewing files that changed from the base of the PR and between 49d45f1 and f3eee91.

📒 Files selected for processing (4)
  • app_test.go
  • client/request_test.go
  • domain_test.go
  • middleware/cors/cors_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • middleware/cors/cors_test.go

Walkthrough

Adds the QUERY HTTP method as a first-class method in Fiber. A MethodQuery = "QUERY" constant is introduced, the method is registered in DefaultMethods, Router and Register interfaces gain Query(...) signatures, and all concrete implementations (App, Group, domainRouter, domainRegistering, Registering) implement the method. IsMethodSafe and methodInt are updated to classify it correctly. CORS, CSRF, and logger middleware are updated, as is the HTTP client with comprehensive test coverage.

Changes

QUERY HTTP Method Integration

Layer / File(s) Summary
Constant and interface contracts
constants.go, app.go, router.go, register.go
Defines MethodQuery = "QUERY", adds internal methodQuery enum and DefaultMethods inclusion, and extends Router and Register public interfaces with the Query method signature.
Routing implementation across App, Group, Domain, and Register
app.go, group.go, domain.go, register.go
Implements Query route-registration methods on App, Group, domainRouter, domainRegistering, and Registering, all delegating to their respective Add helpers.
Method classification and middleware integration
helpers.go, middleware/cors/config.go, middleware/csrf/csrf.go, middleware/logger/utils.go
Maps MethodQuery in methodInt, marks it as safe/idempotent in IsMethodSafe, adds it to CORS ConfigDefault.AllowMethods, classifies it as safe in CSRF middleware, and maps it to cyan in the logger.
HTTP client Query method
client/request.go
Adds Request.Query(url) convenience method that sets the URL, assigns fiber.MethodQuery, and delegates to Send().
Tests and documentation
app_test.go, client/request_test.go, domain_test.go, middleware/cors/cors_test.go, docs/api/constants.md, docs/partials/routing/handler.md, docs/client/request.md
Adds comprehensive test coverage for Query route registration across App, Group, domain routing, and route chains; extends CORS test matrix to include QUERY in Access-Control-Allow-Methods expectations; adds HTTP client Query request test; and updates constants, routing handler, and client request documentation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • gofiber/fiber#3372: Modifies the same App.methodInt/method ID mapping logic in helpers.go and router internals that this PR extends with the MethodQuery case.

Suggested reviewers

  • sixcolors
  • gaby
  • ReneWerner87
  • efectn

Poem

🐇 Hop, hop, a new method appears!
QUERY joins GET and POST with cheers.
Safe and idempotent, cyan and bright,
CORS and CSRF treat it right.
The router hops along its way —
A brand-new verb has come to stay! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding HTTP QUERY method support with an RFC reference, directly addressing the primary objective of the PR.
Description check ✅ Passed The description covers all required sections with clear details on changes, implementation scope, type of change, and completed checklist items, though some optional template sections (benchmarks, migration guide) are not addressed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ReneWerner87 ReneWerner87 added this to v3 Jun 18, 2026
@ReneWerner87 ReneWerner87 added this to the v3 milestone Jun 18, 2026
@nekoworks-magic

nekoworks-magic commented Jun 18, 2026

Copy link
Copy Markdown
Author

I intentionally excluded cache middleware since its signature cannot handle body, maybe some kind of change needed for this?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
middleware/cors/cors_test.go (1)

645-645: ⚡ Quick win

Add a preflight case where Access-Control-Request-Method is QUERY.

These assertions now expect QUERY, but the looped methods table still omits fiber.MethodQuery, so the request-type path for QUERY itself isn’t exercised. Add it to the table to close the test gap.

Also applies to: 679-679

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@middleware/cors/cors_test.go` at line 645, The test assertions at lines 645
and 679 now expect QUERY to be included in the Access-Control-Allow-Methods
header, but the methods table being looped in the preflight test case does not
include fiber.MethodQuery. Add fiber.MethodQuery to the methods table in the
test to ensure the preflight request path for QUERY method is actually exercised
and tested, closing the gap between the assertion expectations and the actual
test coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@middleware/cors/cors_test.go`:
- Line 645: The test assertions at lines 645 and 679 now expect QUERY to be
included in the Access-Control-Allow-Methods header, but the methods table being
looped in the preflight test case does not include fiber.MethodQuery. Add
fiber.MethodQuery to the methods table in the test to ensure the preflight
request path for QUERY method is actually exercised and tested, closing the gap
between the assertion expectations and the actual test coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 364fe260-35d6-4f4f-849e-9255b8bde8c9

📥 Commits

Reviewing files that changed from the base of the PR and between 1148bb6 and 49d45f1.

📒 Files selected for processing (16)
  • app.go
  • app_test.go
  • client/request.go
  • constants.go
  • docs/api/constants.md
  • docs/client/request.md
  • docs/partials/routing/handler.md
  • domain.go
  • group.go
  • helpers.go
  • middleware/cors/config.go
  • middleware/cors/cors_test.go
  • middleware/csrf/csrf.go
  • middleware/logger/utils.go
  • register.go
  • router.go

@ReneWerner87

Copy link
Copy Markdown
Member

I intentionally excluded cache middleware since its signature cannot handle body, maybe some kind of change needed for this?

Yes, we should add that, since the QUERY explicitly states that it can be cached.

@nekoworks-magic

nekoworks-magic commented Jun 18, 2026

Copy link
Copy Markdown
Author

Small changes needed but need to decide how can we generate cache key in defaultKeyGenerator for QUERY request.
I can think adding hash of request body to current result, but need to decide,

  • What hash would be used (blake2b can be used without adding deps and have good performance)
  • How can keep performance great
    etc.

@gaby gaby changed the title 🔥 Feature: Add HTTP QUERY method support (RFC 10008) 🔥 feat: Add HTTP QUERY method support (RFC 10008) Jun 18, 2026
@gaby

gaby commented Jun 18, 2026

Copy link
Copy Markdown
Member
  • Unit-tests missing
  • Documentation missing

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.60%. Comparing base (099802b) to head (42d60ee).

Files with missing lines Patch % Lines
helpers.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4436   +/-   ##
=======================================
  Coverage   91.59%   91.60%           
=======================================
  Files         134      134           
  Lines       13518    13532   +14     
=======================================
+ Hits        12382    12396   +14     
  Misses        722      722           
  Partials      414      414           
Flag Coverage Δ
unittests 91.60% <94.11%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nekoworks-magic

Copy link
Copy Markdown
Author
  • Unit-tests missing
  • Documentation missing

@gaby What documentation and units should be added?
I do not know what documentation needed beside of already edited ones.

@gaby

gaby commented Jun 18, 2026

Copy link
Copy Markdown
Member

Codecov Report

❌ Patch coverage is 35.29412% with 11 lines in your changes missing coverage. Please review. ✅ Project coverage is 91.52%. Comparing base (1148bb6) to head (49d45f1).

Files with missing lines Patch % Lines
domain.go 0.00% 4 Missing ⚠️
client/request.go 0.00% 2 Missing ⚠️
group.go 0.00% 2 Missing ⚠️
register.go 0.00% 2 Missing ⚠️
helpers.go 66.66% 1 Missing ⚠️
Additional details and impacted files
☔ View full report in Codecov by Harness. 📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:

@nekoworks-magic ^ Coverage report

@gaby

gaby commented Jun 18, 2026

Copy link
Copy Markdown
Member

Small changes needed but need to decide how can we generate cache key in defaultKeyGenerator for QUERY request. I can think adding hash of request body to current result, but need to decide,

  • What hash would be used (blake2b can be used without adding deps and have good performance)
  • How can keep performance great
    etc.

That would be a bad idea, a large body would take a while to hash and can be used to cause DoS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants