* feat: Optimize ShutdownWithContext method in app.go
- Reorder mutex lock acquisition to the start of the function
- Early return if server is not running
- Use defer for executing shutdown hooks
- Simplify nil check for hooks
- Remove TODO comment
This commit improves the readability, robustness, and execution order
of the shutdown process. It ensures consistent state throughout the
shutdown and guarantees hook execution even in error cases.
* feat: Enhance ShutdownWithContext test for improved reliability
- Add shutdown hook verification
- Implement better synchronization with channels
- Improve error handling and assertions
- Adjust timeouts for more consistent results
- Add server state check after shutdown attempt
- Include comments explaining expected behavior
This commit improves the comprehensiveness and reliability of the
ShutdownWithContext test, ensuring proper verification of shutdown
hooks, timeout behavior, and server state during long-running requests.
* 📚 Doc: update the docs to explain shutdown & hook execution order
* 🩹 Fix: Possible Data Race on shutdownHookCalled Variable
* 🩹 Fix: Remove the default Case
* 🩹 Fix: Import sync/atomic
* 🩹 Fix: golangci-lint problem
* 🎨 Style: add block in api.md
* 🩹 Fix: go mod tidy
* feat: Optimize ShutdownWithContext method in app.go
- Reorder mutex lock acquisition to the start of the function
- Early return if server is not running
- Use defer for executing shutdown hooks
- Simplify nil check for hooks
- Remove TODO comment
This commit improves the readability, robustness, and execution order
of the shutdown process. It ensures consistent state throughout the
shutdown and guarantees hook execution even in error cases.
* feat: Enhance ShutdownWithContext test for improved reliability
- Add shutdown hook verification
- Implement better synchronization with channels
- Improve error handling and assertions
- Adjust timeouts for more consistent results
- Add server state check after shutdown attempt
- Include comments explaining expected behavior
This commit improves the comprehensiveness and reliability of the
ShutdownWithContext test, ensuring proper verification of shutdown
hooks, timeout behavior, and server state during long-running requests.
* 📚 Doc: update the docs to explain shutdown & hook execution order
* 🩹 Fix: Possible Data Race on shutdownHookCalled Variable
* 🩹 Fix: Remove the default Case
* 🩹 Fix: Import sync/atomic
* 🩹 Fix: golangci-lint problem
* 🎨 Style: add block in api.md
* 🩹 Fix: go mod tidy
* ♻️ Refactor: replaced OnShutdown by OnPreShutdown and OnPostShutdown
* ♻️ Refactor: streamline post-shutdown hook execution in graceful shutdown process
* 🚨 Test: add test for gracefulShutdown
* 🔥 Feature: Using executeOnPreShutdownHooks and executeOnPostShutdownHooks Instead of OnShutdownSuccess and OnShutdownError
* 🩹 Fix: deal Listener err
* 🩹 Fix: go lint error
* 🩹 Fix: reduced memory alignment
* 🩹 Fix: reduced memory alignment
* 🩹 Fix: context should be created inside the concatenation.
* 📚 Doc: update what_new.md and hooks.md
* ♻️ Refactor: use blocking channel instead of time.Sleep
* 🩹 Fix: Improve synchronization in error propagation test.
* 🩹 Fix: Replace sleep with proper synchronization.
* 🩹 Fix: Server but not shut down properly
* 🩹 Fix: Using channels to synchronize and pass results
* 🩹 Fix: timeout with long running request
* 📚 Doc: remove OnShutdownError and OnShutdownSuccess from fiber.md
* Update hooks.md
* 🚨 Test: Add graceful shutdown timeout error test case
* 📝 Doc: Restructure hooks documentation for OnPreShutdown and OnPostShutdown
* 📝 Doc: Remove extra whitespace in hooks documentation
---------
Co-authored-by: yingjie.huang <yingjie.huang@fosunhn.net>
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
* Make tls.Config MinVersion configurable
This commit will resolve#3239
For more info: https://github.com/gofiber/fiber/issues/3239
* Add documents about tls minimum version configurable
* Add if statement for don't allow to use TLS1.0 and TLS1.1
* Fix lint issues, add test for panic()
* Update docs
* Add test with valid TLS version
---------
Co-authored-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
* feat: add a simple support for app.Listen
* fix: fix the nil access error
* chore: add test case for simple tls
* fix: align the struct
* chore: change the test case
can't passed and not chack the file yet
* fix: use TLS1.2 min
* Fix lint issues
* Fix call to os.MkdirTemp
* Fix test check order
* Update unit-tests for ACME
* Update docs
* Fix identation of whats_new examples
* More updates to docs
* Remove ACME tests. Add check for tlsConfig
* Add ACME section to whats_new docs
* Update docs/whats_new.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update fiber.md
* Update whats_new.md
---------
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* 🔥 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>
* 🔥 Feature: Add thread-safe reading from a closed testConn
* 🔥 Feature: Add TestConfig to app.Test()
This commit is summarized as:
- Add the struct `TestConfig` as a parameter for `app.Test()` instead of `timeout`
- Add documentation of `TestConfig` to docs/api/app.md and in-line
- Modify middleware to use `TestConfig` instead of the previous implementation
Fixes#3149
* 📚 Doc: Add more details about TestConfig in docs
* 🩹 Fix: Correct testConn tests
- Fixes Test_Utils_TestConn_Closed_Write
- Fixes missing regular write test
* 🎨 Style: Respect linter in Add App Test Config
* 🎨 Styles: Update app.go to respect linter
* ♻️ Refactor: Rename TestConfig's ErrOnTimeout to FailOnTimeout
- Rename TestConfig.ErrOnTimeout to TestConfig.FailOnTimeout
- Update documentation to use changed name
- Also fix stale documentation about passing Timeout as a
single argument
* 🩹 Fix: Fix typo in TestConfig struct comment in app.go
* ♻️ Refactor: Change app.Test() fail on timeouterror to os.ErrDeadlineExceeded
* ♻️ Refactor:Update middleware that use the same TestConfig to use a global variable
* 🩹 Fix: Update error from FailOnTimeout to os.ErrDeadlineExceeded in tests
* 🩹 Fix: Remove errors import from middlware/proxy/proxy_test.go
* 📚 Doc: Add `app.Test()` config changes to docs/whats_new.md
* ♻ Refactor: Change app.Test() and all uses to accept 0 as no timeout instead of -1
* 📚 Doc: Add TestConfig option details to docs/whats_new.md
* 🎨 Styles: Update docs/whats_new.md to respect markdown-lint
* 🎨 Styles: Update docs/whats_new.md to use consistent style for TestConfig options description
---------
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.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>
* feat!(middleware/session): re-write session middleware with handler
* test(middleware/session): refactor to IdleTimeout
* fix: lint errors
* test: Save session after setting or deleting raw data in CSRF middleware
* Update middleware/session/middleware.go
Co-authored-by: Renan Bastos <renanbastos.tec@gmail.com>
* fix: mutex and globals order
* feat: Re-Add read lock to session Get method
* feat: Migrate New() to return middleware
* chore: Refactor session middleware to improve session handling
* chore: Private get on store
* chore: Update session middleware to use saveSession instead of save
* chore: Update session middleware to use getSession instead of get
* chore: Remove unused error handler in session middleware config
* chore: Update session middleware to use NewWithStore in CSRF tests
* test: add test
* fix: destroyed session and GHSA-98j2-3j3p-fw2v
* chore: Refactor session_test.go to use newStore() instead of New()
* feat: Improve session middleware test coverage and error handling
This commit improves the session middleware test coverage by adding assertions for the presence of the Set-Cookie header and the token value. It also enhances error handling by checking for the expected number of parts in the Set-Cookie header.
* chore: fix lint issues
* chore: Fix session middleware locking issue and improve error handling
* test: improve middleware test coverage and error handling
* test: Add idle timeout test case to session middleware test
* feat: add GetSession(id string) (*Session, error)
* chore: lint
* docs: Update session middleware docs
* docs: Security Note to examples
* docs: Add recommendation for CSRF protection in session middleware
* chore: markdown lint
* docs: Update session middleware docs
* docs: makrdown lint
* test(middleware/session): Add unit tests for session config.go
* test(middleware/session): Add unit tests for store.go
* test(middleware/session): Add data.go unit tests
* refactor(middleware/session): session tests and add session release test
- Refactor session tests to improve readability and maintainability.
- Add a new test case to ensure proper session release functionality.
- Update session.md
* refactor: session data locking in middleware/session/data.go
* refactor(middleware/session): Add unit test for session middleware store
* test: fix session_test.go and store_test.go unit tests
* refactor(docs): Update session.md with v3 changes to Expiration
* refactor(middleware/session): Improve data pool handling and locking
* chore(middleware/session): TODO for Expiration field in session config
* refactor(middleware/session): Improve session data pool handling and locking
* refactor(middleware/session): Improve session data pool handling and locking
* test(middleware/csrf): add session middleware coverage
* chroe(middleware/session): TODO for unregistered session middleware
* refactor(middleware/session): Update session middleware for v3 changes
* refactor(middleware/session): Update session middleware for v3 changes
* refactor(middleware/session): Update session middleware idle timeout
- Update the default idle timeout for session middleware from 24 hours to 30 minutes.
- Add a note in the session middleware documentation about the importance of the middleware order.
* docws(middleware/session): Add note about IdleTimeout requiring save using legacy approach
* refactor(middleware/session): Update session middleware idle timeout
Update the idle timeout for the session middleware to 30 minutes. This ensures that the session expires after a period of inactivity. The previous value was 24 hours, which is too long for most use cases. This change improves the security and efficiency of the session management.
* docs(middleware/session): Update session middleware idle timeout and configuration
* test(middleware/session): Fix tests for updated panics
* refactor(middleware/session): Update session middleware initialization and saving
* refactor(middleware/session): Remove unnecessary comment about negative IdleTimeout value
* refactor(middleware/session): Update session middleware make NewStore public
* refactor(middleware/session): Update session middleware Set, Get, and Delete methods
Refactor the Set, Get, and Delete methods in the session middleware to use more descriptive parameter names. Instead of using "middlewareContextKey", the methods now use "key" to represent the key of the session value. This improves the readability and clarity of the code.
* feat(middleware/session): AbsoluteTimeout and key any
* fix(middleware/session): locking issues and lint errors
* chore(middleware/session): Regenerate code in data_msgp.go
* refactor(middleware/session): rename GetSessionByID to GetByID
This commit also includes changes to the session_test.go and store_test.go files to add test cases for the new GetByID method.
* docs(middleware/session): AbsoluteTimeout
* refactor(middleware/csrf): Rename Expiration to IdleTimeout
* docs(whats-new): CSRF Rename Expiration to IdleTimeout and remove SessionKey field
* refactor(middleware/session): Rename expirationKeyType to absExpirationKeyType and update related functions
* refactor(middleware/session): rename Test_Session_Save_Absolute to Test_Session_Save_AbsoluteTimeout
* chore(middleware/session): update as per PR comments
* docs(middlware/session): fix indent lint
* fix(middleware/session): Address EfeCtn Comments
* refactor(middleware/session): Move bytesBuffer to it's own pool
* test(middleware/session): add decodeSessionData error coverage
* refactor(middleware/session): Update absolute timeout handling
- Update absolute timeout handling in getSession function
- Set absolute expiration time in getSession function
- Delete expired session in GetByID function
* refactor(session/middleware): fix *Session nil ctx when using Store.GetByID
* refactor(middleware/session): Remove unnecessary line in session_test.go
* fix(middleware/session): *Session lifecycle issues
* docs(middleware/session): Update GetByID method documentation
* docs(middleware/session): Update GetByID method documentation
* docs(middleware/session): markdown lint
* refactor(middleware/session): Simplify error handling in DefaultErrorHandler
* fix( middleware/session/config.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* add ctx releases for the test cases
---------
Co-authored-by: Renan Bastos <renanbastos.tec@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: René <rene@gofiber.io>
* feat: add rebuild tree method
* docs: add newline at the end of app.md
* docs: add an example of dynamic defined routes
* docs: remove tabs from example code on app.md
* Update docs/api/app.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update app.md
* docs: add RebuildTree to what's new documentation
* fix: markdown errors in documentation
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* refactor: add mutex lock to the addRoute function
* refactor: remove mutex lock from addRoute
* refactor: fix mutex deadlock in addRoute
---------
Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* added startup default probe endpoint
* added test case
* updated docs
* updated test order
* added test case
* fixed go fmt and md lint
* fixed go fmt and md lint
* updated doc as per coderabbitai suggestions
* changed healhtcheck route register to use default const instead of string for test cases
* updated whats new with healthcheck content
* updated whats new doc with coderabbitai sugg
* updated migration guide
* 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>
* Support for key length, Add benchmarks for EncryptCookie middleware
* Format tests
* Add tests for panics and key check in Encryptor and Decryptor functions
* Add tests for base64 decoding errors
* Update docs/middleware/encryptcookie.md
Co-authored-by: Jason McNeil <sixcolors@mac.com>
* Update middleware/encryptcookie/utils.go
Co-authored-by: Jason McNeil <sixcolors@mac.com>
* Add suggestions from code review
---------
Co-authored-by: Jason McNeil <sixcolors@mac.com>
* Add an option to invalidate cache
* Add a summary about the cache middleware update
* Rename the option to make it clearer
* Rename hard tab
* Fix markdown formatting
* Revert unnecessary change
* Clarify the description of cache invalidator
* Add empty line
---------
Co-authored-by: RW <rene@gofiber.io>
* docs: add docs for new client
* Add docs for client hooks
* Add docs for client examples
* Some fixes.
* docs: add docs for new client
* docs: add docs for new client
* Add more examples for methods
* Update docs/client/examples.md
Co-authored-by: Jason McNeil <sixcolors@mac.com>
* Add one more example for cookiejar
* apply review
* apply review
* apply review
* docs: add docs for new client
* docs: add docs for new client
---------
Co-authored-by: René <rene@gofiber.io>
Co-authored-by: Jason McNeil <sixcolors@mac.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