* feat: Add All method to Bind
This commit introduces a new `All` method to the `Bind` struct, enabling the binding of request data from multiple sources (URI parameters, body, query parameters, headers, and cookies) into a single struct.
The `All` method iterates through the available binding sources, applying them in a predefined precedence order. It merges the values from each source into the output struct, only updating fields that are currently unset.
Changes:
- Added `All` method to `Bind` struct.
- Added `mergeStruct` helper function to merge struct values.
- Added `isZero` helper function to check if a value is zero.
- Added a test case for the `All` method in `bind_test.go` to validate its functionality.
* feat: Enhance Bind.All with comprehensive testing and configuration
The changes include:
- Added `RequestConfig` struct to encapsulate request configuration (ContentType, Body, Headers, Cookies, Query).
- Implemented `ApplyTo` method on `RequestConfig` to apply the configuration to the context.
- Created multiple test cases for `Bind.All` covering successful binding, missing fields, overriding query parameters, and form binding.
- Added a test case `Test_Bind_All_Uri_Precedence` to validate the precedence of URI parameters.
- Added benchmark test `BenchmarkBind_All` to measure the performance of the `Bind.All` method.
- Refactored the `TestBind_All` to use the new `RequestConfig` and assertion libraries.
* fix: Correct form binding in Test_Bind_All
* refactor: Improve Bind.All test and struct field ordering
- Reordered fields in `RequestConfig` and `User` structs for field alignment
- Updated `Test_Bind_All` to use `require.NoError` for more robust error checking.
- Corrected header key casing in `Test_Bind_All` to `X-User-Role` to match the struct tag.
- Added `t.Parallel()` to the test function to enable parallel test execution.
* feat: Document Bind.All function in API documentation
This commit adds documentation for the `Bind.All` function to the API documentation.
The documentation includes:
- A description of the function's purpose and precedence order for binding data from different sources (URI, body, query, headers, cookies).
* docs: lint Bind.All documentation
* fix: Update parameter tags from 'param' to 'uri' in bind_test.go
* fix: Update parameter tags from 'param' to 'uri' in bind.md
* test: Replace assert with require in bind_test.go
* feat: Add support for unified binding with defined precedence order in whats_new.md
---------
Co-authored-by: RW <rene@gofiber.io>
* Fix nil pointer dereference with Must Bind binding error
if err is nil err.Error() panics
(eg. c.Bind().Must().JSON(...) successfully binds but panics
* Added returnErr test
make sure returnErr works with nil error
* Reordered returnErr nil check
as in majority of cases we expect err to be nil, this should provide better short-cutting
* Use require.NoError
* Update bind_test.go
* Renamed Must to WithAutoHandling
* Update bind.md
Added a requested clarification
* renamed Should to WithoutAutoHandling and Bind.should to Bind.dontHandle
* renamed dontHandle to dontHandleErrs
* fixed formatting
* fixed a typo
* Update binder documentation
---------
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
* Add support for consistent documentation using markdownlint
* Only run workflow during changes to markdown files
* Fix more inconsistencies
* Fixes to markdown under .github/
* More fixes
* Apply suggestions from code review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Fix typo in limiter docs
* Add missing space before code-block
* Add check for dead-links
* Add write-good
* Remove legacy README files
* Fix glob for skipping .md files
* Use paths-ignore instead
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3
* [v3 Maintenance]: Consolidate and Document Core Changes in v3