845 Commits

Author SHA1 Message Date
Juan Calderon-Perez
5566b59ed7
Update middleware/proxy/proxy.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-25 10:35:40 -04:00
Juan Calderon-Perez
a809afb542 Run betteralign on proxy config 2025-07-25 10:12:30 -04:00
Juan Calderon-Perez
b533ac7792 docs: note proxy KeepConnectionHeader 2025-07-25 00:55:40 -04:00
RW
05f8ac0255
🔥 feat: Add config for Timeout middleware (#3604)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-07-20 15:22:08 +02:00
RW
5dffcb6d84
[Static]: Improve sanitizePath performance (#3601) 2025-07-20 13:50:44 +02:00
Juan Calderon-Perez
93be63c229
🧹 chore: Improve static middleware security (#3595) 2025-07-20 10:35:53 +02:00
Jason McNeil
e17bab7946
Refactor CSRF middleware and enhance documentation (#3598)
Co-authored-by: RW <rene@gofiber.io>
2025-07-19 20:11:33 +02:00
René
d5842860eb fix Benchmark_MemoryLock
panic: runtime error: index out of range [1] with length 1

goroutine 67 [running]:
github.com/gofiber/fiber/v3/middleware/idempotency_test.Benchmark_MemoryLock(0xc00012c2c8)
	/home/runner/work/fiber/fiber/middleware/idempotency/locker_test.go:74 +0x23d
testing.(*B).runN(0xc00012c2c8, 0x1)
	/opt/hostedtoolcache/go/1.24.4/x64/src/testing/benchmark.go:219 +0x190
testing.(*B).run1.func1()
	/opt/hostedtoolcache/go/1.24.4/x64/src/testing/benchmark.go:245 +0x48
created by testing.(*B).run1 in goroutine 1
	/opt/hostedtoolcache/go/1.24.4/x64/src/testing/benchmark.go:238 +0x90
exit status 2
2025-07-18 08:55:06 +02:00
René
16fd8edbf1 fix Benchmark_MemoryLock
panic: runtime error: index out of range [1] with length 1

goroutine 67 [running]:
github.com/gofiber/fiber/v3/middleware/idempotency_test.Benchmark_MemoryLock(0xc00012c2c8)
	/home/runner/work/fiber/fiber/middleware/idempotency/locker_test.go:74 +0x23d
testing.(*B).runN(0xc00012c2c8, 0x1)
	/opt/hostedtoolcache/go/1.24.4/x64/src/testing/benchmark.go:219 +0x190
testing.(*B).run1.func1()
	/opt/hostedtoolcache/go/1.24.4/x64/src/testing/benchmark.go:245 +0x48
created by testing.(*B).run1 in goroutine 1
	/opt/hostedtoolcache/go/1.24.4/x64/src/testing/benchmark.go:238 +0x90
exit status 2
2025-07-18 08:53:53 +02:00
M. Efe Çetin
192d1dff0d
feat: add context methods to fiber.Storage interface (#3566)
* feat: add context methods to fiber.Storage interface

* fix linter

* create new file for storage interface (storage_interface.go)

* add simple context check to internal storage

* update docs

* add fallback context for session

---------

Co-authored-by: René <rene@gofiber.io>
2025-07-18 03:19:50 +02:00
RW
2f8fdc454b
Add modernize lint (#3590) 2025-07-17 14:48:43 +02:00
Juan Calderon-Perez
c1e9ae3ff9
🐛 bug: Fix static/favicon middlewares file descriptor leaks (#3579) 2025-07-14 15:16:57 +02:00
Juan Calderon-Perez
8ef317cbae
🐛 bug: Fix missing Allow header in EnvVar middleware per RFC 9110 (#3570) 2025-07-11 08:42:57 +02:00
RW
dd739687d3
Refactor fasthttp iter calls to range loops (#3559)
refactor: replace fastHTTP iter calls with for loops
2025-07-01 14:14:56 +02:00
dependabot[bot]
eddecf22e4
build(deps): bump github.com/valyala/fasthttp from 1.62.0 to 1.63.0 (#3557)
* build(deps): bump github.com/valyala/fasthttp from 1.62.0 to 1.63.0

Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.62.0 to 1.63.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.62.0...v1.63.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-version: 1.63.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump github.com/valyala/fasthttp from 1.62.0 to 1.63.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: René <rene@gofiber.io>
2025-07-01 11:06:50 +02:00
Juan Calderon-Perez
d79fa01f0f
🐛 bug: Fix Content-Disposition header per RFC 6266 (#3551)
* Use raw UTF-8 filenames in Content-Disposition

* Fix lint issues

* Fix issue with new funct

* Improve and fix quoteRawString

* fix issues

* Fix lint issues

* fix golangci-lint

* Update static_test.go

* Update static_test.go
2025-06-30 09:06:11 +02:00
Juan Calderon-Perez
bdd9e22bd7
🐛 bug: Fix Cache middleware handling of Age (#3547)
* Revert benchmark loop changes

* test: cover Age header parsing

* generate msgp files

* Update cache.go

* Cast result

* Update cache.go
2025-06-30 09:04:35 +02:00
Juan Calderon-Perez
b08d0bfd2f
🐛 bug: Fix Cache-Control header parsing (#3534)
* refactor: use utils.ToLower

* Improve Cache-Control directive matching

* Update middleware/cache/cache.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix lint issue

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-23 07:42:12 +02:00
Juan Calderon-Perez
e1a7c114b2
🧹 chore: Improve CSRF tests coverage (#3531)
test(csrf): cover cookie config warnings
2025-06-20 08:47:57 +02:00
Juan Calderon-Perez
6d16bf5605
🧹chore: Improve BasicAuth middleware default security (#3522)
* Refine BasicAuth middleware

* Fix lint issues

* Update basicauth.md
2025-06-20 08:47:35 +02:00
Juan Calderon-Perez
aea0fd230f
🧹 chore: Improve CORS tests coverage (#3530)
* test(cors): warn when all origins and func

* Fix linter issue
2025-06-20 08:47:05 +02:00
Juan Calderon-Perez
528462d2bd
🧹 chore: Add missing CSRF token extractor tests (#3527)
test: cover missing form error
2025-06-18 08:25:05 +02:00
Juan Calderon-Perez
a35c5d2e15
🧹 chore: Improve Helmet middleware tests coverage (#3523)
* test: add HSTS coverage

* Update middleware/helmet/helmet_test.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update helmet_test.go

* Update helmet_test.go

* Revert test changes

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-06-17 23:24:49 +02:00
Juan Calderon-Perez
0590709556
🧹 chore: Improve Idempotency middleware tests coverage (#3521)
* Consolidate idempotency tests

* Fix lint issues

* Fix more lint issues

* Fix lint issue
2025-06-16 17:45:40 +02:00
Juan Calderon-Perez
1ce3182951
🧹 chore: Improve EarlyData middleware tests coverage (#3520)
* test: move config tests into earlydata_test

* Fix lint issue
2025-06-16 17:44:32 +02:00
Jason McNeil
670fbd5e45
feat: Add support for Keys() in session middleware (#3517)
*  feat: Update session middleware add Keys method and update docs to match key type any

*  test: Add /keys endpoint to set and retrieve multiple session keys

*  test: Refactor /keys endpoint to trim whitespace and improve key handling in session tests
2025-06-13 11:40:17 +02:00
Juan Calderon-Perez
b29171ce40
🧹 chore: Improve CORS middleware response headers (#3505)
* Improve CORS middleware

* 🐛 fix: Remove unused 'slices' import from CORS middleware

---------

Co-authored-by: Jason McNeil <sixcolors@mac.com>
2025-06-10 08:47:34 +02:00
Juan Calderon-Perez
3a60cf7a4e
🧹 chore: Refactor EnvVar middleware (#3513)
* remove ExcludeVars option

* Simplify envvar export logic
2025-06-10 08:40:58 +02:00
Juan Calderon-Perez
80f4f99c01
🧹 chore: Fix typos in code and docs (#3507)
chore: fix spelling mistakes across codebase
2025-06-07 22:34:44 +02:00
Juan Calderon-Perez
5eb1432c81
🐛 fix: Middlewares immutable config handling (#3494)
* Respect immutable flag in middlewares

* Add unit-tests for Immutable
2025-06-01 13:53:18 +02:00
Juan Calderon-Perez
09d9e169b2
🧹 chore: Enhance config validation in EncryptCookie middleware (#3491)
* test: validate encryptcookie config key

* simplified logic and remove duplicated code

* remove extra spaces
2025-05-28 15:12:57 +02:00
Juan Calderon-Perez
a779888d44
🧹 chore: Improve cache middleware RFC compliance (#3488)
* test: cover cache enhancements

* Fix lint issues and tests names

* Fix test

* Use utils.ToLower()

* Use utils.Trim

* Add missing param
2025-05-28 13:59:06 +02:00
Oleksandr Redko
956205311b
♻️ refactor: use maps.Copy to simplify code (#3490) 2025-05-28 12:49:33 +02:00
tongjicoder
557095b094
♻️ refactor: use slices.Contains to simplify code (#3486)
refactor: use slices.Contains to simplify code

Signed-off-by: tongjicoder <tongjicoder@icloud.com>
2025-05-27 20:03:22 +02:00
Jason McNeil
7559758b02
🧪 test: Enhance CSRF tests to address unsafe header value issue (#2045) (#3485)
* 🧪 test: Enhance CSRF tests to address unsafe header value issue (#2045)

* Update middleware/csrf/csrf_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-27 19:18:25 +02:00
Juan Calderon-Perez
47f47ae2d8
🧹 chore: Enhance BasicAuth middleware to better comply with RFC 6750 (#3484)
* test(basicauth): ensure whitespace tolerant

* use utils.TrimSpace

* Update docs
2025-05-27 14:27:45 +02:00
Juan Calderon-Perez
804a2b923e
🧹 chore: Enhance KeyAuth middleware to better comply with RFC 6750 (#3482)
* docs(keyauth): add Realm option

* Add unit-test for GenericError case

* Update keyauth_test.go

* Backport fixes

* Update keyauth_test.go

* Fix spacing

* Add test for empty value

* Remove extra comma

* Add missing closing brace

* Review comments

* add missing import

* Add more unit-tests

* remove inconclusive test
2025-05-27 14:07:42 +02:00
RW
c2eee63183
🧹 chore: Update minimum go version to 1.24 (#3481)
* chore: update docs and workflows for go1.24

* Fix listen bug

* Use b.Loop() for benchmarks https://go.dev/blog/testing-b-loop

* Use b.Loop() for benchmarks https://go.dev/blog/testing-b-loop

* Revert b.Loop() for some benchmarks

* Change genericParser benchmarks (runParallel)

* Change Benchmark_Router_Github_API benchmarks (runParallel)
2025-05-27 13:23:02 +02:00
pj
9bd7a1c50d
feat: fiber.Context implement context.Context (#3382)
* Ctx implements context.Context

* fix up some linting issues

* added some tests

* no message

* fiber.Ctx implements context.Context

* no message

* implement compile-time check

* update formatting

* update compile-time checks

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2025-05-26 08:53:18 +02:00
RW
e722d82206
️ Performance optimizations (#3477)
adpater / HTTPHandler
NEW
Benchmark_HTTPHandler-12    	 1762837	       640.6 ns/op	     696 B/op	      10 allocs/op
Benchmark_HTTPHandler-12    	 1924524	       616.5 ns/op	     696 B/op	      10 allocs/op
Benchmark_HTTPHandler-12    	 1838780	       650.4 ns/op	     696 B/op	      10 allocs/op
Benchmark_HTTPHandler-12    	 1876947	       644.0 ns/op	     696 B/op	      10 allocs/op
OLD
Benchmark_HTTPHandler-12    	 1864819	       667.2 ns/op	     720 B/op	      11 allocs/op
Benchmark_HTTPHandler-12    	 1892569	       677.0 ns/op	     720 B/op	      11 allocs/op
Benchmark_HTTPHandler-12    	 1811704	       639.5 ns/op	     720 B/op	      11 allocs/op
Benchmark_HTTPHandler-12    	 1879849	       644.0 ns/op	     720 B/op	      11 allocs/op

Utils / IsNoCache
NEW
Benchmark_Utils_IsNoCache-12    	44307204	        27.08 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	40782919	        26.88 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	44228217	        26.69 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	45605700	        26.75 ns/op	       0 B/op	       0 allocs/op
OLD
Benchmark_Utils_IsNoCache-12    	30043908	        37.80 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	32137476	        37.51 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	31474653	        37.92 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	31838683	        37.71 ns/op	       0 B/op	       0 allocs/op
2025-05-25 17:23:03 +02:00
dependabot[bot]
3ff2d378ab
build(deps): bump github.com/valyala/fasthttp from 1.60.0 to 1.62.0 (#3440)
* build(deps): bump github.com/valyala/fasthttp from 1.60.0 to 1.62.0

Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.60.0 to 1.62.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.60.0...v1.62.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-version: 1.62.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix CSRF middleware tests for fasthttp 1.62 (#3471)

Fix CSRF tests for fasthttp 1.62

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: RW <rene@gofiber.io>
2025-05-24 11:21:50 +02:00
RW
aae8892c7e
Improve proxy middleware (#3468) 2025-05-23 10:47:05 +02:00
Juan Calderon-Perez
18ed68b543
🧹 chore: Fix proxy middleware tests for offline environments (#3467)
* Fix proxy middleware tests to avoid external network

* Update proxy_test.go

* Update middleware/proxy/proxy_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update proxy_test.go

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-22 14:07:06 +02:00
RW
119743b726
🚀 Improve routing treeBuild flow (#3456)
* improve routing treeBuild flow

* improve routing treeBuild flow
2025-05-16 08:30:05 +02:00
Isaac Andrade
4321dfed55
♻️ refactor: Change c.Redirect() default status (#3415)
* Set default redirect response status to 303 SeeOther

Closes #3405

In some browsers, redirect status 302 Found sometimes is used to change
the HTTP verb of the response from what the user set to what was used in
the request. Changing to 303 SeeOther in the default works more like
expected: it defaults to GET and can be overriden by the user.

* Add tests to Redirect default status change.

* Update docs.

* Fix remaining tests to reflect redirect 303 status as the new default. Reflect that in docs/whats_new.md

* Update redirect_test.go

* Fix code review hints

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: René <rene@gofiber.io>
2025-05-12 14:56:23 +02:00
Yorick de Wid
057647a579
🔥 feat: Add support for ForceColors in Logger middleware (#3428)
* Force the use of terminal colors via config option

* docs: add example for forcing terminal colors in logger middleware

* test: add benchmarks for logger middleware with forced colors

* Add ForceColors field to 'whats new'

* Show example in 'whats new'
2025-05-09 13:58:41 +02:00
Jason McNeil
b3e84860d2
Revert "🔥 feat: Add Context Support to RequestID Middleware" (#3365)
Revert "🔥 feat: Add Context Support to RequestID Middleware (#3200)"

This reverts commit f725ded92bac13e773f92ff478e1a461c160abd3.

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2025-04-08 08:59:24 +02:00
RW
62b099879a
🧪 fix: Logger Middleware tests to use regex for time validation (#3392)
* test: rewrite logger format tests to use regex for time validation

* test: rewrite logger format tests to use regex for time validation
2025-04-03 13:36:30 +02:00
Jason McNeil
bb12633c8b
Revert "🔥 feat: Add support for context.Context in keyauth middleware" (#3364)
Revert "🔥 feat: Add support for context.Context in keyauth middleware (#3287)"

This reverts commit 4177ab4086a97648553f34bcff2ff81a137d31f3.

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2025-03-31 16:55:01 +02:00
Juan Calderon-Perez
75281bd874
🧹 chore: Simplify HealthCheck middleware (#3380)
* Simplify middleware

* Rename default endpoints
2025-03-30 11:46:52 +02:00