* Add Drop method to DefaultCtx and remove redundant checks
Introduced a Drop method in DefaultCtx for closing connections, enabling easier resource management. Removed unnecessary nil-checks for headers in manager_msgp to simplify code logic. Added a unit test to ensure the new Drop method behaves as expected.
* Add `Drop` method to Fiber context API documentation
The `Drop` method allows silently terminating client connections without sending HTTP headers or a response body. This is useful for scenarios like mitigating DDoS attacks or blocking unauthorized access to sensitive endpoints. Example usage and function signature are included in the updated documentation.
* Remove extraneous blank line in documentation.
Eliminated an unnecessary blank line in the API context documentation for improved readability and formatting consistency. No functional changes were made to the content.
* Update API documentation example to return "Hello World!"
Revised the example code in the API documentation to return a generic "Hello World!" string instead of a dynamic response. This improves consistency and simplifies the example for easier understanding.
* Refactor Drop method and extend test coverage.
Simplified the Drop method by inlining the connection close call. Added new test cases to ensure proper handling of no-response scenarios and improved overall test coverage.
* fix golangci-lint issue
* Add test for Ctx.Drop with middleware interaction
This test ensures the correct behavior of the Ctx.Drop method when used with middleware, including response handling and error scenarios. It verifies that the middleware and handler properly handle the Drop call and its resulting effects.
* Add Drop method to DefaultCtx for closing connections
The Drop method allows closing connections without sending a response, improving control over connection handling. Also updated a test assertion to use StatusOK for improved readability and consistency.
* Refine Drop method comments to clarify error handling.
Explain the rationale for not wrapping errors in the Drop method. Emphasize that the returned error is solely for logging and not for further propagation or processing.
* Update Drop method documentation for clarity
Clarified the `Drop` method's behavior, specifying that it closes the connection without sending headers or a body. Added examples of use cases, such as DDoS mitigation and blocking sensitive endpoints.
* Refactor response header setting in middleware.
Replaced the direct header setting with the `Set` method for consistency and improved clarity. Removed a test case checking for a panic on closed response body as it is no longer applicable.
* 🔥 Feature: Add SendStreamWriter to Ctx
Create a new `*DefaultCtx` method called `SendStreamWriter()`
that maps to fasthttp's `Response.SetBodyStreamWriter()`
* 🚨 Test: Validate regular use of c.SendStreamWriter()
- Adds Test_Ctx_SendStreamWriter to ctx_test.go
* 🚨 Test: (WIP) Validate interrupted use of c.SendStreamWriter()
- Adds Test_Ctx_SendStreamWriter_Interrupted to ctx_test.go
- (Work-In-Progress) This test verifies that some data is
still sent before a client disconnects when using the method
`c.SendStreamWriter()`.
**Note:** Running this test reports a race condition when using
the `-race` flag or running `make test`. The test uses a channel
and mutex to prevent race conditions, but still triggers a warning.
* 📚 Doc: Add `SendStreamWriter` to docs/api/ctx.md
* 🩹 Fix: Remove race condition in Test_Ctx_SendStreamWriter_Interrupted
* 🎨 Styles: Update ctx_test.go to respect golangci-lint
* 📚 Doc: Update /docs/api/ctx.md to show proper `w.Flush()` error handling
* 📚 Doc: Add SendStreamWriter details to docs/whats_new.md
* 🎨 Styles: Update /docs/whats_new.md to respect markdownlint-cli2
* 🩹 Fix: Fix Fprintf syntax error in docs/whats_new.md
---------
Co-authored-by: M. Efe Çetin <efectn@protonmail.com>
* Rename UserContext() to Context(). Rename Context() to RequestCtx()
* Update Ctxt docs and What's new
* Remove extra blank lines
---------
Co-authored-by: M. Efe Çetin <efectn@protonmail.com>
* enhancement: use msgp for flash message encoding/decoding
* add msgp tests
* improve test coverage
* improve test coverage
* fix linter
* update makefile
* extend go generation process
---------
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: René <rene@gofiber.io>
* docs: Improve ctx.Locals method description, godoc and example
* docs: Update ctx.md to use value receiver for fiber.Ctx in app.Use and app.Get
* chore: Update userKey type in ctx.md
* docs: Update ctx.md
* chore: Add description for Locals method in Ctx interface