Commit Graph

274 Commits (v2)

Author SHA1 Message Date
Juan Calderon-Perez 42d921d353
🧹 chore: Backport ctx.String() from v3 (#3294)
* Backport ctx.String() to v2

* Fix lint issues
2025-01-27 15:00:51 +01:00
RW 7eb9d25548
Support Square Bracket Notation in Multipart Form data (#3268)
* Feature Request: Support Square Bracket Notation in Multipart Form Data #3224

* Feature Request: Support Square Bracket Notation in Multipart Form Data #3224
2024-12-31 16:56:18 +01:00
nickajacks1 56ff2de858
🐛 fix: Respect Immutable config for Body() (#3246)
* 🐛 fix: respect Immutable config for Body()

* ci: add go 1.22 and 1.23 to test matrix
2024-12-13 08:28:36 +01:00
Vaibhav Gupta cb06bc5f4c
🩹 Fix: handle un-matched open brackets in the query params (#3121)
* Add logic for counting open brackets

* Add UTs

* update increment/decrement syntax with ++/--

* Update UT to remove duplicate
2024-09-06 08:02:02 +02:00
Jason McNeil 232c0fac0d
docs: Improve ctx.Locals method documentation (#3033) 2024-06-12 16:23:15 +02:00
Jongmin Kim e524b73524
Fix default value to false in docs of QueryBool (#2811)
fix default value to false in docs of QueryBool
2024-01-28 18:28:47 +01:00
Reid Hurlburt 9f082af045
🔥 Add support for application/problem+json (#2704)
🔥 Add support for custom JSON content headers
2023-11-13 15:18:05 +01:00
nickajacks1 5d888cee3d
️ perf(ctx.Range): reduce allocations (#2705)
* perf(ctx.Range): reduce allocations

strings.Split was causing extra allocations where using
strings.IndexByte can suffice. ALso switch from strconv.Atoi because it
causes an allocation when parsing a non-integer, which is common for
Ranges.

* chore: fix lint
2023-11-10 11:32:25 +01:00
René Werner af3999835f Add more description to GetClientInfo 2023-10-16 10:35:42 +02:00
joey1123455 e70b2e28d6
Cookie parser (#2656)
* prep for branching

* feature: added a cookie parser and tests appropriate tests

*  feature: added a cookie parser and appropriate tests

* made correction to docs

* linted using gofumpt

* ctx_test linted, cookieParser schema added

* fix lint errors (Cookie parser #2656)

* removed extra lines, tested return values

---------

Co-authored-by: René Werner <rene.werner@verivox.com>
2023-10-12 10:44:15 +02:00
Tiago Peczenyj 9230be3649
Fix jsonp ignoring custom json encoder (#2658)
* add unit test to trigger the bug #2675

* implement solution
2023-10-05 10:09:29 +02:00
M. Efe Çetin fa88733218
🐛 bug: fix PassLocalsToView when bind parameter is nil (#2651)
* 🐛 bug: fix PassLocalsToView when bind parameter is nil

* fix linter
2023-09-28 14:40:59 +02:00
M. Efe Çetin a9447a5b49
ctx: change signatures of GetReqHeaders and GetRespHeaders (#2650)
* ctx: change signatures of GetReqHeaders and GetRespHeaders

* fix middlewares
2023-09-28 08:31:31 +02:00
dairlair c89184c155
♻️ Refactor Ctx.Method func to improve code readability (#2647)
* Refactor Ctx.Method func to improve code readability

* Fix the lint issue with extra tab on blank line
2023-09-26 08:15:33 +02:00
huykn 640fd1f7c7
🐛 fix parse ips return invalid in abnormal case (#2642)
* 🐛 fix parse ips return invalid in abnormal case

* ♻️ change benchmark to test cases

---------

Co-authored-by: Khúc Ngọc Huy <huykn0710@gmail.com>
2023-09-21 11:06:02 +02:00
huykn 59d3eb0762
🐛 fix bug parse custom header (#2638)
* 🐛 fix bug parse custom header

* 🚨 fix lint when request merge https://github.com/gofiber/fiber/pull/2638

---------

Co-authored-by: Khúc Ngọc Huy <huykn0710@gmail.com>
2023-09-19 18:00:26 +02:00
René Werner b8c9ede6ef IsFromLocal corrected 2023-09-06 13:20:33 +02:00
Jian Lim 8ec7cec435
♻️ Refactor: Use Global vars instead of local vars for isLocalHost (#2595)
♻️ Refactor: Use Global vars instead of local vars for isLocalHost
2023-08-23 12:19:22 +02:00
M. Efe Çetin 1dea615ddf
🔥 add config to enable splitting by comma in parsers (#2560)
* 🔥 add config to enable splitting by comma in parsers

🔥 add config to enable splitting by comma in parsers

* optimize if statements, remove escape char support

optimize if statements, remove escape char support

* update
2023-08-21 09:44:02 +02:00
João Victor Oliveira Couto f29f39b1b3
fix: Decompress request body when multi Content-Encoding sent on request headers (#2555)
* 🔧 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
2023-08-06 17:23:37 +02:00
André da Silva 58270e2d5b
🩹 Fix: dictpool is not completely gone (#2540)
* Completely remove dictpool

Looks like issue:
https://github.com/gofiber/fiber/issues/2209
Was not complete. So here dictpool is completely gone

* Fix linting error
2023-07-11 09:06:32 +02:00
Moein Halvaei 5967d36bc0
✏️ Fix typo (#2518)
* Fix: typo in client.go

* Fix: typo in ctx.go

* Fix: typo in path.go

* Fix: typo in router.go

* Fix: typo in adaptor.go
2023-06-23 16:15:38 +02:00
Iliya d87065f5f2
🚀 FEATURE: add queries function (#2475)
* 🚀 FEATURE: add queries method

* 📚 DOCS: add documents for queries method.

* 🩹 Fix: fix wrap error returned from Queries function

* 🚨 tests: add url encoded tests

* 🔥 feature: add url encoded support for queries

* 🩹 Fix: fix wrap error returned from Queries function

* ♻️ Refactor: change error message of url.QueryUnescape

* ♻️ Refactor: refactor of mapping key and value queries

* 🚨 Test: Validate to fail parse queries

* 🚨 Test: Add benchmark test for Queries

* 🩹 Fix: remove parsing for encoded urls

* ♻️ Refactor: change string function to c.app.getString fucntion

Co-authored-by: cmd777 <83428931+cmd777@users.noreply.github.com>

* ♻️ Refactor: change name of benchamark function ctx queries

Co-authored-by: leonklingele <git@leonklingele.de>

* ♻️ Refactor: remove empty lines

Co-authored-by: leonklingele <git@leonklingele.de>

* Revert "♻️ Refactor: change string function to c.app.getString fucntion"

This reverts commit 28febf9e60.

* 📚 Docs: add documents for queries method

* 🚨 Tests: add more tests for queries function

* ♻️ Refactor: change string function to c.app.getString function

* 🚨 Tests: add more test for queries function

* 📚 Docs: add more documents to queries function

---------

Co-authored-by: cmd777 <83428931+cmd777@users.noreply.github.com>
Co-authored-by: leonklingele <git@leonklingele.de>
2023-06-12 07:51:57 +02:00
cmd777 4c12938309
♻️ Refactor: use c.app.getString instead of string(...) (#2489)
use c.app.getString instead of string(...)
2023-06-01 10:47:07 +02:00
Iliya bf31f1f3c6
💊 Change default value of Querybool from true to false. (#2391)
* 🩹 Fix QueryBool function: change default value from true to false

* 📚 Update QueryBool function document

* Update ctx.md

---------

Co-authored-by: RW <rene@gofiber.io>
2023-03-30 13:26:26 +02:00
RW 28d9abb71b
Fix #2383, accepts mimeType (#2386)
* Fix #2383, accepts mimeType

* Fix #2383, accepts mimeType

* Fix #2383, accepts mimeType
2023-03-27 15:55:41 +02:00
Iliya c3b151a1fe
🔥 Feature: add queryBool parser (#2329)
* 🔥 Feature: add queryBool parser

* 🩹 pass linter
2023-02-09 22:33:09 +08:00
Iliya 54439a5bde
🔥 Feature: add queryFloat parser (#2328) 2023-02-09 13:44:13 +08:00
leonklingele ac4ce21d9c
🐛 Bug: Fix issues introduced in linting PR (#2319)
* 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>
2023-02-02 15:57:40 +01:00
leonklingele 167a8b5e94
🚀 Feature: Add and apply more stricter golangci-lint linting rules (#2286)
* 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
2023-01-27 09:01:37 +01:00
Iliya a0004cf8a8
🔥 write integer Query Parser. (#2306)
* Feature: write integer Query Parser.

* request changes on https://github.com/gofiber/fiber/pull/2306#discussion_r1082171003

* ref(test): separate test cases for QueryInt
2023-01-23 19:06:12 +01:00
M. Efe Çetin 8a605c67d1
🩹 bug: use `app.getString, app.GetBytes` instead of `utils.UnsafeString, utils.UnsafeBytes` in `ctx.go` (#2297)
* 🩹 bug: use `app.getString, app.GetBytes` instead of `utils.UnsafeString, utils.UnsafeBytes` in `ctx.go`

* fix Test_Client_Debug
2023-01-15 20:56:53 +08:00
Angel ILIEV 356448cb66
Update docstring for FormValue() (#2262)
Include the other places that are searched for the provided form value key
2022-12-05 15:02:18 +01:00
leonklingele d9d2153fcc
🩹 Fix: Properly handle error of "net.ParseCIDR" in "(*App).handleTrustedProxy" (#2243)
* app: do not use empty *net.IPNet in case of an error of "net.ParseCIDR"

* app: expose error returned by "net.ParseCIDR"

* ctx: do not repeatedly call method in loop

* ctx: add test for "IsProxyTrusted" func
2022-12-05 08:27:51 +01:00
Clark Winters f3679167ff
🩹 Fix: Unintended overwritten bind variables (#2240)
* bindMap key value should only be set when not already present

* add comment

Co-authored-by: Clark Winters <clwinters8@gmail.com>
2022-12-01 09:18:23 +01:00
RW e4b3b5c708
Improve interface for custom logger func (#2225)
* - 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
2022-11-18 15:32:56 +01:00
leonklingele 235cd9df82
ctx: simplify Protocol() (#2217)
* ctx: simplify Protocol()

* ctx: also mention "X-Url-Scheme" header in Protocol()

* ctx: use the same warning comment about enabling Config.EnableTrustedProxyCheck everywhere
2022-11-14 08:32:48 +01:00
leonklingele b288a9f54e
ctx: make Secure() also report whether a secure connection was established to a trusted proxy (#2215)
We had a discussion about this in https://github.com/gofiber/helmet/pull/74.
2022-11-14 08:22:35 +01:00
Rafi Muhammad 878c9549d8
Feat: Register custom methods (#2107)
* Implementing register custom methods

* Return timout time to 1000

* Update app_test.go

* Change update stack to add custom request method

* Feat: Register custom methods #2107

* Feat: Register custom methods #2107

* update logic

* optimization.

* fix

Co-authored-by: Rafi Muhammad <rafi.muhammad@mekari.com>
Co-authored-by: RW <rene@gofiber.io>
Co-authored-by: Muhammed Efe Çetin <efectn@protonmail.com>
2022-11-11 08:23:30 +01:00
pj ff4602980a
- update Locals function to accept interface{} key (#2144)
- update Locals function to accept interface{} key (Requires new version of fasthttp)

Co-authored-by: rocketlaunchr-cto <rocketlaunchr.cloud@gmail.com>
2022-10-27 07:51:08 +02:00
M. Efe Çetin 691d2e6ad5
🗑️ deprecate: go 1.14 & go 1.15 support deprecation (#2172)
* 🗑️ deprecate: go 1.14 & go 1.15 support deprecation
https://github.com/valyala/fasthttp/pull/1379

* fix tests
2022-10-26 11:51:50 +02:00
M. Efe Çetin 156b81c768
🐛 bug: improve mounting behavior (#2120)
* 🐛 bug: fix mounting doesn't work if when to declare it before routes

* 🐛 bug: fix mounting doesn't work if when to declare it before routes

* 🐛 bug: fix mounting doesn't work if when to declare it before routes

* 🐛 bug: fix mounting doesn't work if when to declare it before routes

* 🐛 bug: fix mounting doesn't work if when to declare it before routes

* add onMount hooks, mountPath like express.js, better behavior for onName, onRoute, onGroup, onGroupName hooks on mounted apps

* add comment

* use once

* fix views when both app and sub-app have view engine, better behavior for mount path

* fix tests

* fix tests

* make some tasks

* make some tasks
2022-10-25 07:51:44 +02:00
sadfun 5316f0823d
🚀 Make IP validation 2x faster (#2158)
* 🚀 Make IP vallidation 2x faster

* Add tests for IP validation

* phrasing & linter fix

* change test assert function

That was a surprise that testing style in gofiber/utils and in gofiber/fiber/utils are different 😳
2022-10-18 11:59:23 +02:00
Supakorn Wongsawang 709b132dca
🩹 Fix: handle multiple X-Forwarded header (#2154)
* fix: handle multiple XForwarded

* fix: use strings.Index instead of strings.Split

Co-authored-by: Supakorn Wongsawang <supakorn.wongsawang@agoda.com>
2022-10-18 11:23:35 +02:00
Soham Sen 9a6002056c
Switch to text/javascript as per RFC9239 (#2146)
* Switch to text/javascript as per RFC9239

* Add deprecated flag to application/javascript
2022-10-10 14:29:51 +02:00
kinggo 896b37183f
🐛 fix: same struct parse param failed (#2101)
fix: same struct parse param failed
2022-09-19 10:58:04 +02:00
Amir Hossein 1d773c7f3c
update code comments for helping IDEs and fix unhandled error in test (#2099)
* fix unhandled errors

* fix unhandled error in cache package test

* omit variable type

* omit variable type

* rename variable because collide with the imported package name

* handle file error on closing

* fix unhandled in common_linux.go

* fix unhandled errors in helpers_test.go

* fix unhandled errors in listen_test.go

* remove unused parameter in emptyHandler method

* refactor path.go

* unhandled error in hooks test

* fix unhandled errors in app_test.go

* fix unhandled errors in ctx_test.go

*  fix unhandled errors in helpers_test.go

* revert app_test.go

* remove redundant parentheses and update comments

* update code comment for helping ide

* update code comment for helping ide

* fix unhandled error in app_test.go

* update code comments for helping IDEs
2022-09-18 15:32:54 +02:00
René Werner e829caf808 correct ctx release for viewBindMap 2022-09-16 15:22:55 +02:00
Trim21 709c52301c
fix `ctx.SendStream(io.Reader)` huge memory usage (#2091)
* Update ctx.go

* remove content-length from test
2022-09-15 07:19:25 +02:00
Amir Hossein f482b303b5
remove redundant parentheses and update comments (#2082)
* fix unhandled errors

* fix unhandled error in cache package test

* omit variable type

* omit variable type

* rename variable because collide with the imported package name

* handle file error on closing

* fix unhandled in common_linux.go

* fix unhandled errors in helpers_test.go

* fix unhandled errors in listen_test.go

* remove unused parameter in emptyHandler method

* refactor path.go

* unhandled error in hooks test

* fix unhandled errors in app_test.go

* fix unhandled errors in ctx_test.go

*  fix unhandled errors in helpers_test.go

* revert app_test.go

* remove redundant parentheses and update comments
2022-09-11 13:09:39 +02:00