4220 Commits

Author SHA1 Message Date
Kashiwa
0ebe65d711
♻️ refact(state): Use GetState to reduce duplicate code (#3542)
♻️ refact: use GetState to reduce duplicate code
2025-06-23 18:11:29 +02:00
Juan Calderon-Perez
a258661de3
🐛 bug: Fix Subdomains() parsing for IDNs (#3538)
* Use utils.ToLower in Subdomains

* test: cover Unicode fallback path

* fix subdomain extraction for rfc compliance

* Address review comments on Subdomains

* Address review comments
2025-06-23 14:59:34 +02:00
RW
e58db87475
Add custom constraint example (#3539)
docs: add custom constraint example
2025-06-23 12:52:24 +02:00
RW
ad64f2cd8f
Add NewWithCustomCtx initialization helper (#3476)
* Make custom context setup via NewWithCustomCtx

* Update docs/api/app.md

* fix lint issues

* small optimizations

* Fix perf 3476 (#3499)

* perf: modify app.pool

goos: darwin
goarch: arm64
pkg: github.com/gofiber/fiber/v3
cpu: Apple M4
                       │   old.txt   │              new.txt               │
                       │   sec/op    │   sec/op     vs base               │
_Communication_Flow-10   36.26n ± 0%   34.51n ± 0%  -4.83% (p=0.000 n=30)

                       │  old.txt   │            new.txt             │
                       │    B/op    │    B/op     vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

                       │  old.txt   │            new.txt             │
                       │ allocs/op  │ allocs/op   vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

* perf: optimize defaultCtx in app.next

```
goos: darwin
goarch: arm64
pkg: github.com/gofiber/fiber/v3
cpu: Apple M4
                       │   new.txt   │              new4.txt               │
                       │   sec/op    │   sec/op     vs base                │
_Communication_Flow-10   34.51n ± 0%   30.02n ± 0%  -13.01% (p=0.000 n=30)

                       │  new.txt   │            new4.txt            │
                       │    B/op    │    B/op     vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

                       │  new.txt   │            new4.txt            │
                       │ allocs/op  │ allocs/op   vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal
```

---------

Co-authored-by: Kashiwa <13825170+ksw2000@users.noreply.github.com>

* Improve performance #3476 (#3532)

* Make custom context setup via NewWithCustomCtx

* Update docs/api/app.md

* fix lint issues

* small optimizations

* perf: modify app.pool

goos: darwin
goarch: arm64
pkg: github.com/gofiber/fiber/v3
cpu: Apple M4
                       │   old.txt   │              new.txt               │
                       │   sec/op    │   sec/op     vs base               │
_Communication_Flow-10   36.26n ± 0%   34.51n ± 0%  -4.83% (p=0.000 n=30)

                       │  old.txt   │            new.txt             │
                       │    B/op    │    B/op     vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

                       │  old.txt   │            new.txt             │
                       │ allocs/op  │ allocs/op   vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

* perf: optimize defaultCtx in app.next

```
goos: darwin
goarch: arm64
pkg: github.com/gofiber/fiber/v3
cpu: Apple M4
                       │   new.txt   │              new4.txt               │
                       │   sec/op    │   sec/op     vs base                │
_Communication_Flow-10   34.51n ± 0%   30.02n ± 0%  -13.01% (p=0.000 n=30)

                       │  new.txt   │            new4.txt            │
                       │    B/op    │    B/op     vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

                       │  new.txt   │            new4.txt            │
                       │ allocs/op  │ allocs/op   vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal
```

* perf: revert nextCustom

```
goos: darwin
goarch: arm64
pkg: github.com/gofiber/fiber/v3
cpu: Apple M4
                       │  head.txt   │            revert-1.txt            │
                       │   sec/op    │   sec/op     vs base               │
_Communication_Flow-10   30.04n ± 0%   28.74n ± 0%  -4.33% (p=0.000 n=30)

                       │  head.txt  │          revert-1.txt          │
                       │    B/op    │    B/op     vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

                       │  head.txt  │          revert-1.txt          │
                       │ allocs/op  │ allocs/op   vs base            │
_Communication_Flow-10   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal
```

---------

Co-authored-by: RW <rene@gofiber.io>

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: Kashiwa <13825170+ksw2000@users.noreply.github.com>
2025-06-23 12:47:52 +02:00
dependabot[bot]
b06ce1327f
build(deps): bump github.com/gofiber/utils/v2 from 2.0.0-beta.8 to 2.0.0-beta.9 (#3540)
build(deps): bump github.com/gofiber/utils/v2

Bumps [github.com/gofiber/utils/v2](https://github.com/gofiber/utils) from 2.0.0-beta.8 to 2.0.0-beta.9.
- [Release notes](https://github.com/gofiber/utils/releases)
- [Commits](https://github.com/gofiber/utils/compare/v2.0.0-beta.8...v2.0.0-beta.9)

---
updated-dependencies:
- dependency-name: github.com/gofiber/utils/v2
  dependency-version: 2.0.0-beta.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-23 12:31:59 +02:00
Juan Calderon-Perez
fcf5755c7c
🐛 bug: Fix Content-Type comparison in Is() (#3536)
* test: validate Is fails for JSON subtype

* Update ctx.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update ctx.go

* Use immutable-aware getter for Content-Type

* Update ctx.go

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: RW <rene@gofiber.io>
2025-06-23 08:04:21 +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
3b2af61152
🧹 chore: Improve Binder tests coverage (#3529)
* Move binder tests into existing file

* Fix lint issues and race condition

* Add nolint directive
2025-06-19 08:28:49 +02:00
Juan Calderon-Perez
c6e0d802f3
🧹 chore: Update codecov configuration (#3528)
* Add root level ignores for codecov

* Update codecov.yml
2025-06-19 08:28:19 +02:00
Juan Calderon-Perez
a68b0e0883
🧹 chore: Improve hooks test coverage (#3524)
* move extra tests into hooks_test

* refactor: reuse mount path constant in tests

* Update test.yml

* Add codecov.yml
2025-06-18 14:56:31 +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
2831d75423
🧹 chore: Improve Retry addon tests coverage (#3526)
* test(retry): achieve full coverage

* Fix lint issue

* Update addon/retry/exponential_backoff_test.go

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

* Update exponential_backoff_test.go

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-06-18 08:24:39 +02:00
Juan Calderon-Perez
eceabc51aa
🧹 chore: Remove repo codecov.yml (#3525)
Remove repo base codecov.yml
2025-06-18 08:24:18 +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
d93ea9e14d
Merge pull request #3516 from MonkyMars/modernize-loop
♻️ refactor: Update loop syntax for retry mechanism
2025-06-12 21:05:53 -04:00
Levi Noppers
f2ac588f13 🐛 fix: Update loop syntax for retry mechanism to use range for clarity 2025-06-12 17:17:38 +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
Jason McNeil
73e919621b
📒 docs: Enhance CORS middleware documentation with preflight request details and infrastructure considerations (#3509)
* docs: Enhance CORS middleware documentation with preflight request details and infrastructure considerations

* docs: Update CORS middleware documentation with infrastructure handling options and best practices

* docs: fix CORS middleware documentation markdown linting issues
2025-06-10 08:46:19 +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
f00e35529c
Merge pull request #3504 from gofiber/dependabot/go_modules/github.com/gofiber/schema-1.5.0
build(deps): bump github.com/gofiber/schema from 1.4.0 to 1.5.0
2025-06-07 16:39:56 -04:00
Juan Calderon-Perez
0523b6a1c7
Merge pull request #3506 from gofiber/dependabot/go_modules/golang.org/x/crypto-0.39.0
build(deps): bump golang.org/x/crypto from 0.38.0 to 0.39.0
2025-06-07 16:38:37 -04: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
dependabot[bot]
d83d4613ce
build(deps): bump golang.org/x/crypto from 0.38.0 to 0.39.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.38.0 to 0.39.0.
- [Commits](https://github.com/golang/crypto/compare/v0.38.0...v0.39.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-06 12:22:43 +00:00
dependabot[bot]
e2f26e7c8c
build(deps): bump github.com/gofiber/schema from 1.4.0 to 1.5.0
Bumps [github.com/gofiber/schema](https://github.com/gofiber/schema) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/gofiber/schema/releases)
- [Commits](https://github.com/gofiber/schema/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/gofiber/schema
  dependency-version: 1.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-05 12:52:12 +00:00
Juan Calderon-Perez
f9eec854fd
🐛 fix: Subdomains offset handling (#3495)
* Fix Subdomains offset handling

* Update docs, add extra unit-tests

* update logic and tests

* update logic

* fix lint

* Update docs and tests

* Update ctx.go

* update docs

* update docs

* update docs

* add test case for port

* Update offset documentation
2025-06-05 09:36:21 +02:00
RW
9409e4ff0c
📒 docs: Remove deprecated comments and documenting recent changes (#3498)
* removing deprecated comments and documenting the changes in the whats new overview

* removing deprecated comments and documenting the changes in the whats new overview
2025-06-04 08:20:00 +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
0328b7baa7
Merge pull request #3492 from gofiber/dependabot/github_actions/kenchan0130/actions-system-info-1.3.1
build(deps): bump kenchan0130/actions-system-info from 1.3.0 to 1.3.1
2025-05-30 01:36:40 -04: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
dependabot[bot]
788f702988
build(deps): bump kenchan0130/actions-system-info from 1.3.0 to 1.3.1
Bumps [kenchan0130/actions-system-info](https://github.com/kenchan0130/actions-system-info) from 1.3.0 to 1.3.1.
- [Release notes](https://github.com/kenchan0130/actions-system-info/releases)
- [Commits](https://github.com/kenchan0130/actions-system-info/compare/v1.3.0...v1.3.1)

---
updated-dependencies:
- dependency-name: kenchan0130/actions-system-info
  dependency-version: 1.3.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-28 12:29:51 +00: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
René
a590cdbcdd Skipped Benchmarks: too fast to compare reliably (results in sub-ns range are unstable)
Benchmark_GenericParseTypeInts
Benchmark_GenericParseTypeUints
Benchmark_GenericParseTypeFloats
2025-05-27 19:50:43 +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
Juan Calderon-Perez
23fb15f704
🔥 feat: Add support for NewErrorf (#3463)
* feat: support variadic messages in NewError

* Improve implementation and tests

* Update status code

* Update test

* Lint fixes

* More updates to test

* lint fixes

* add nolint

* Update app.go

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

* Update app.go

* Update app.go

* Use utils.ToString

* Add NewErrorf, revert changes

* Update docs

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-27 13:23:29 +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
RW
da0aec0d64
Improve performance for "equalFieldType" function (#3479)
Improve performance for "equalFieldType" function

OLD:
```
Benchmark_equalFieldType-12    	 3320424	       361.0 ns/op	      80 B/op	       9 allocs/op
```

NEW:
```
Benchmark_equalFieldType-12    	11102847	       102.2 ns/op	      16 B/op	       3 allocs/op
```
+
solve the problem with passing on the tag name
2025-05-27 10:48:36 +02:00
RW
d756ec1b68
🧹 chore: Add URI Test case for Test_Ctx_Binders (#3480)
Add Uri Test case for Test_Ctx_Binders
2025-05-26 21:45:58 +02:00
René
0c6283fbff Fix docs issues 2025-05-26 09:34:50 +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
Kashiwa
a5f76a7bee
♻️ refactor: Make genericParseType return error (#3473)
* ♻️ refact: make genericParseType return error

* 🐛 fix: return error when parsing unsupported type

* 🚨 test: cover the default value for Params

* 🚨 test: cover default value on parsing error

* ♻️ refact: change the benchmark name

* 🚨 test: remove the duplicated maxUint16 test case

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2025-05-25 23:54:03 +02:00