The limiter middleware unit tests are failing due to a race between the
storage garbage collector and the unit test itself. The sliding window
limiter tracks requests using memory storage. In several of the unit
tests, this storage expiry ends up being 4 seconds. The test waits for 4
seconds, then sends a request, expecting it to succeed. However, the
unit test occasionally wakes up before the storage GC kicks in. As an
effect of the very coarse timer (using seconds as units), the middleware
correctly rejects the request, causing the test to fail.
Update the sleep to 4.5 seconds. This will not slow down the execution
of the test suite, as these tests run in parallel with a separate 9
second long test.
I'm not 100% sure this solves the issue, and ideally we'd be able to
run tests without time.Sleep.
From the Go docs:
"If the map is nil, the number of iterations is 0." [1]
Therefore, an additional nil check for before the loop is unnecessary.
[1]: https://go.dev/ref/spec#For_range
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* fix: default logger formater latency
* test: add Test_Logger_WithLatency_DefaultFormat
* test: rm t.Parallel() from Latency tests
Trying to make windows CI pass....
* test: fix windows sleep issue
* 🔧 feat: Decode body in order when sent a list on content-encoding
* 🚀 perf: Change `getSplicedStrList` to have 0 allocations
* 🍵 test: Add tests for the new features
* 🍵 test: Ensure session test will not raise an error unexpectedly
* 🐗 feat: Replace strings.TrimLeft by utils.TrimLeft
Add docs to functions to inform correctly what the change is
* 🌷 refactor: Apply linter rules
* 🍵 test: Add test cases to the new body method change
* 🔧 feat: Remove return problems to be able to reach original body
* 🌷 refactor: Split Body method into two to make it more maintainable
Also, with the previous fix to problems detected by tests, it becomes really hard to make the linter happy, so this change also helps in it
* 🚀 perf: Came back with Header.VisitAll, to improve speed
* 📃 docs: Update Context docs
* ✨ feat(cors): Added new 'AllowOriginsFunc' function.
* feat(cors): Added warning log for when both 'AllowOrigins' and 'AllowOriginsFunc' are set.
* feat(docs): Updated docs to include note about discouraging the use of this function in production workloads.
---------
Co-authored-by: RW <rene@gofiber.io>
* feature: session only for zero expire cookie #2145
* refactor condition to set MaxAge and Expire on cookie
* move checking zero maxage and expire in session middleware
Signed-off-by: Yves Tumushimire <yvestumushimire@gmail.com>
* feature: session only for zero expire cookie #2145
* refactor condition to set MaxAge and Expire on cookie
* move checking zero maxage and expire in session middleware
Signed-off-by: Yves Tumushimire <yvestumushimire@gmail.com>
* CR changes
* some updates
---------
Signed-off-by: Yves Tumushimire <yvestumushimire@gmail.com>
Co-authored-by: Muhammed Efe Çetin <efectn@protonmail.com>
Co-authored-by: René Werner <rene.werner@verivox.com>
* Add support for DoRedirects
Signed-off-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
* Fix linter issues
Signed-off-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
* Add example to README
* Add support for DoDeadline and DoTimeout. Expand unit-tests
* Fix linter errors
Signed-off-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
* Add examples for Proxy Middleware
---------
Signed-off-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
* basic_auth: extend benchmark for uppercase Basic
* basic_auth: check space after basic (and avoid alloc if Basic)
* fixup! basic_auth: check space after basic (and avoid alloc if Basic)
* add forward from domain
* add balancer forward
* add unittest and readme
* add short description new feature
* add short description on signature
* golangci-lint fix
---------
Co-authored-by: René Werner <rene@gofiber.io>
* PR: add url for favicon middleware, for correct handling different of ico formats
* pr: efectn > URL would be better naming i think
* pr: add test case
* apply reviews
* remove json annotinos, since they are unnecessary
* readme fixes
* linting fixes
---------
Co-authored-by: koalan <kolesnikov.khv@gmail.com>
Co-authored-by: Muhammed Efe Çetin <efectn@protonmail.com>
* ✅ chore: add go 1.20 to ci and readmes
* 🧹 chore: add go 1.20 to ci and readmes
* update linter
* fix linter
* fix benchmarks
* fix benchmarks
* fix benchmarks
* internal: revert linting changes
Changes to the internal package should not have been made in 167a8b5e94.
* middleware/monitor: revert changes to exported field "ChartJSURL"
This is a breaking change introduced in 167a8b5e94.
* middleware/monitor: fix error checking
Fix the errorenous error checking introduced in 167a8b5e94.
* 🐛 Bug: Fix issues introduced in linting PR #2319
* 🐛 Bug: Fix issues introduced in linting PR #2319
* Bug: Fix issues introduced in linting PR #2319
---------
Co-authored-by: René Werner <rene@gofiber.io>
* golangci-lint: add and apply more stricter linting rules
* github: drop security workflow now that we use gosec linter inside golangci-lint
* github: use official golangci-lint CI linter
* Add editorconfig and gitattributes file
* 🚀 Feature: Add idempotency middleware (#2253)
* middleware: add idempotency middleware
* middleware/idempotency: use fiber.Storage instead of custom storage
* middleware/idempotency: only allocate data if really required
* middleware/idempotency: marshal response using msgp
* middleware/idempotency: add msgp tests
* middleware/idempotency: do not export response
* middleware/idempotency: disable msgp's -io option to disable generating unused methods
* middleware/idempotency: switch to time.Duration based app.Test
* middleware/idempotency: only create closure once
* middleware/idempotency: add benchmarks
* middleware/idempotency: optimize strings.ToLower when making comparison
The real "strings.ToLower" still needs to be used when storing the data.
* middleware/idempotency: safe-copy body
* middleware/idempotency: backport to v2
* middleware: add idempotency middleware
* middleware/idempotency: use fiber.Storage instead of custom storage
* middleware/idempotency: only allocate data if really required
* middleware/idempotency: marshal response using msgp
* middleware/idempotency: add msgp tests
* middleware/idempotency: do not export response
* middleware/idempotency: disable msgp's -io option to disable generating unused methods
* middleware/idempotency: switch to time.Duration based app.Test
* middleware/idempotency: only create closure once
* middleware/idempotency: add benchmarks
* middleware/idempotency: optimize strings.ToLower when making comparison
The real "strings.ToLower" still needs to be used when storing the data.
* middleware/idempotency: safe-copy body
app: make app.Test accept a time.Duration timeout
Cases found by running semgrep with an empty .semgrepignore file
semgrep --lang=go -e '$O.Test($X, $Y)'
* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal
* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal
* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal
* - logger: fix custom tag
- use real bytebufferpool dependency instead of the internal
* Add URL prefix to pprof middleware
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
* Minor tweak
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>