feat(binding): add support for binding whole request at once#4543
feat(binding): add support for binding whole request at once#4543takanuva15 wants to merge 2 commits intogin-gonic:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4543 +/- ##
==========================================
- Coverage 99.21% 98.39% -0.83%
==========================================
Files 42 49 +7
Lines 3182 3170 -12
==========================================
- Hits 3157 3119 -38
- Misses 17 42 +25
- Partials 8 9 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ea54884 to
3a5ca23
Compare
|
@appleboy All PR checks passing. Ready for review |
There was a problem hiding this comment.
Pull request overview
Adds a new “bind everything” capability to Gin’s Context so a single call can bind headers, URI params, query params, and request body into one struct, with validation applied after all parts are bound.
Changes:
- Introduce
Context.BindAll/Context.ShouldBindAllto bind headers + URI + query + body in one call. - Add a new internal-style binding engine
binding.All(viaBindingMany) to perform multi-source binding and defer validation. - Document the new API and add unit tests covering success + validation failure paths.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
context.go |
Adds BindAll / ShouldBindAll methods that delegate to binding.All. |
binding/all.go |
Implements the new multi-source binder that binds header/uri/query then binds body via binding.Default. |
binding/binding.go |
Adds BindingMany interface and exports All binder (non-nomsgpack build). |
binding/binding_nomsgpack.go |
Adds BindingMany interface and exports All binder (nomsgpack build). |
binding/binding_test.go |
Adds unit tests for binding.All across header/uri/query/body and failure cases. |
context_test.go |
Adds tests for Context.BindAll and Context.ShouldBindAll. |
docs/doc.md |
Documents “Bind All” usage with an end-to-end example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
15e33b4 to
5355337
Compare
|
@appleboy Addressed all comments. Ready for re-review |
|
@takanuva15 If the AI recommendations have already been implemented, please click the Resolve button to indicate that the issue has been addressed. |
|
@appleboy done, comments resolved. Ready for rereview |
With this PR, users can now call
c.BindAllto allow Gin to bind headers, request path params, query params, and body in a single call. This resolves a number of tickets regarding this functionality:relates to #1824
relates to #2309
closes #2535
closes #2758
closes #2919
closes #4338
closes #3095
closes #4510
MVE:
Test it with:
Pull Request Checklist
Please ensure your pull request meets the following requirements:
masterbranch.docs/doc.md.Thank you for contributing!