Commit Graph

245 Commits (167a8b5e9421e0ab51fbf44c5621632f4a1a90c5)

Author SHA1 Message Date
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
M. Efe Çetin 4d28b1e200
🐛 bug: make tlsHandler public to use it with Listener (#2034)
* 🐛 bug: ClientHelloInfo support for app.Listener

* 🐛 bug: ClientHelloInfo support for app.Listener

* fix

* make tlshandler public

* update

* 🐛 bug: make tlsHandler public to use it with Listener #2034

Co-authored-by: wernerr <rene@gofiber.io>
2022-08-24 09:47:37 +02:00
Jinquan Wang 9c98a1fb37
🐛 bug: Case sensitivity for parameters in GetRouteURL (#2010)
* 🐛 bug: Case sensitivity for parameters in GetRouteURL

* ✏️ perf: error spell
2022-08-24 09:16:19 +02:00
George Bolo 8540d0afdc
fixes #2016 - make IP() and IPs() more reliable (#2020)
* fixes #2016 - make IP() and IPs() more reliable

* improve the performance of IP validation functionality

* refactor IP validation and make it a configuration option
2022-08-23 08:32:21 +02:00
Thomas 2edcf95f57
update: tls.ClientHelloInfo in Ctx (#2011)
* Update go.mod

* wip

* wip

* wip

* wip

* wip

* Move tlsHandler from Config to App

* Use NewError instead of panic

* Add a test with ServerName

* Add some tests on ClientHelloInfo

* fix missing import

* remove unnecessary ctx field.

Co-authored-by: RW <rene@gofiber.io>
Co-authored-by: Muhammed Efe Çetin <efectn@protonmail.com>
2022-08-19 08:19:22 +02:00
M. Efe Çetin 95abdacba0
feature: add XML to context. (#2003)
*  feature: add XML to context.

* Update app.go
2022-08-16 08:05:35 +02:00
olongfen bad7001570
binds the param string to a struct use params tag (#1968)
* add: params parse

* fix: binds the param string to a struct use params tag
2022-07-06 12:42:54 +02:00
olongfen dfa24a0958
add: params parse (#1964) 2022-07-05 13:45:11 +02:00
Sujit Baniya 3bb4b7ed41
Fix GetLocationFromRoute bug for optional params (#1922)
* Add Global Layout for view render

* Add test case for Views Layout

* Update ctx_test.go

* Add App Name function to pass custom app name

* Remove json tag for function

* Change func to string

* Add test for AppName

* Add RedirectToRoute and RedirectBack with fallback if referer in header not found

* replace errors.New with fmt.Errorf

* simplified code

* Add tests for different formats

* Add method to get route location and add benchmarks

* Add ToString function

* Fix error

* rearrange case for fmt.Stringer

* Fix bug for error return

* Lock latest route for app.Name(namee string)

* decreasing timeout for client test with timeout

* remove println and adjust condition to > 0

* Change name to get route url

* Change name to get route url

* Update ctx.go

Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>

* Fix bug on getting url for optional and greedy params

* Fix greedy pattern

* This PR will fix #1921 (comment).

The optional and greedy params were not fetched correctly

* This PR will fix #1921 (comment).

The optional and greedy params were not fetched correctly

* This PR will fix #1921 (comment).

The optional and greedy params were not fetched correctly

Co-authored-by: RW <rene@gofiber.io>
Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>
2022-05-31 13:58:13 +02:00
Artem Avanesov 061c2a9e12
fix typo for paramsInt function (#1913) 2022-05-24 02:05:55 +02:00
dependabot[bot] bf0673eb95
Bump github.com/valyala/fasthttp from 1.35.0 to 1.37.0 (#1882)
* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0

Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.35.0 to 1.36.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.35.0...v1.36.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  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.35.0 to 1.36.0 #1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 #1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 #1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 #1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 #1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.37.0 #1882

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: wernerr <rene@gofiber.io>
2022-05-18 08:16:19 +02:00
ChandanChainani 941ada9f05
Fix cannot process array of values in `application/x-www-form-urlencoded` request (#1873)
* Renamed parseQuery to parseParamSquareBrackets

* Added square brackets processing for `application/x-www-form-urlencoded`

* Added test cases for Array of form values
2022-04-24 12:25:36 +02:00
TomRomeo bea756f624
✏️ Typo fix in ParamsInt() (#1863) 2022-04-16 15:32:25 -04:00
RW e9151e8ab8
Revert " feature: add SendFileWithConfig method to ctx (#1852)" (#1861)
This reverts commit f19ef67f73.
2022-04-15 15:54:18 +02:00
M. Efe Çetin c42af6d2ca
feature: support adding queries to RedirectToRoute (#1858)
* Support adding queries for RedirectToRoute method.

* fix security check.

*  feature: support adding queries to RedirectToRoute

Co-authored-by: wernerr <rene@gofiber.io>
2022-04-15 15:32:39 +02:00
M. Efe Çetin f19ef67f73
feature: add SendFileWithConfig method to ctx (#1852)
* add sendfilewithconfig.

* update

* shortify code.
2022-04-14 10:49:48 +02:00
M. Efe Çetin a63a842fb6
add allparams method. (#1853) 2022-04-14 10:48:41 +02:00
M. Efe Çetin ee65ea5bab
🧹 Use encoding/json (#1851)
* remove goccy/go-json

* fix tests.
2022-04-13 10:45:33 +02:00
Andrey Kuvshinov 16b8717a29
Add context Writef feature function (#1841) 2022-04-01 19:15:06 +02:00
Neenad Ingole 44bfdc3d6b
🩹 Allow parsing of square bracket query param (#1818) 2022-03-22 09:13:56 +01:00
Sujit Baniya af339a851f
Change name to get URL from (#1831)
* Add Global Layout for view render

* Add test case for Views Layout

* Update ctx_test.go

* Add App Name function to pass custom app name

* Remove json tag for function

* Change func to string

* Add test for AppName

* Add RedirectToRoute and RedirectBack with fallback if referer in header not found

* replace errors.New with fmt.Errorf

* simplified code

* Add tests for different formats

* Add method to get route location and add benchmarks

* Add ToString function

* Fix error

* rearrange case for fmt.Stringer

* Fix bug for error return

* Lock latest route for app.Name(namee string)

* decreasing timeout for client test with timeout

* remove println and adjust condition to > 0

* Change name to get route url

* Change name to get route url

* Update ctx.go

Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>

Co-authored-by: RW <rene@gofiber.io>
Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>
2022-03-22 09:13:30 +01:00
Geet Manghnani a746e5bfb8
Restore Original URL of the context after changing it (#1788)
* Restore original URL after the proxy

* Use the Immutable string to restore

* Changing deprecated ImmutableString to CopyString

Co-authored-by: Geet Manghnani <gmanghna@in.ibm.com>
2022-02-20 21:59:47 +01:00
M. Efe Çetin 937713e41e
feature: bind support for render (#1754)
* Bind support for Render.

* update

* fix tests

* split Pass-locals-to-views & Bind from Render

* update comments.

* add benchs.

* Update ctx.go

Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>

* Update ctx.go

* optimize

* switch dictpool.

*  feature: bind support for render
- improve performance

*  feature: bind support for render
- improve performance

Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>
Co-authored-by: wernerr <rene.werner@verivox.com>
Co-authored-by: wernerr <rene@gofiber.io>
2022-02-12 22:52:24 +01:00
Sujit Baniya 505e4d77a7
[FEATURE REQUEST] - Add RedirectToRoute and RedirectBack (#1750)
* Add Global Layout for view render

* Add test case for Views Layout

* Update ctx_test.go

* Add App Name function to pass custom app name

* Remove json tag for function

* Change func to string

* Add test for AppName

* Add RedirectToRoute and RedirectBack with fallback if referer in header not found

* replace errors.New with fmt.Errorf

* simplified code

* Add tests for different formats

* Add method to get route location and add benchmarks

* Add ToString function

* Fix error

* rearrange case for fmt.Stringer

* Fix bug for error return

* Lock latest route for app.Name(namee string)

* decreasing timeout for client test with timeout

* remove println and adjust condition to > 0

Co-authored-by: RW <rene@gofiber.io>
2022-02-09 09:02:45 +01:00
Abhishek Mehandiratta 68fcd8c88f
Feature: Session Only Cookies (#1752)
* feat(ctx): add SessionOnly property on Cookie struct

* feat(middleware/config): add CookieSessionOnly property on middleware Config struct

* feat(csrf): link config CookieSessionOnly with fiber.Cookie in create middleware function

* fix(ctx_test): add tests for SessionOnly cookie in test_ctx_cookie

* fix(readme): update readme in csrf middleware for CookieSessionOnly property

* remove deprecated property from CookieSessionOnly explaination comments
2022-02-07 13:35:00 +01:00
M. Efe Çetin c450072f4a
🐛 fix: mounted app views (#1749)
* Fix mounted app views.

* Cleaner structure.

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

* remove unnecessary lines.

* Add test case for group-with-mount, remove unnecessary lines.

Co-authored-by: RW <rene@gofiber.io>
2022-02-06 14:58:45 +01:00
Matthias Neugebauer 8853190031
🔥 Feature: Add ability to restart route handling (#1739)
* 🔥 Feature: Add ability to restart route handling

* Change test names

Co-authored-by: RW <rene@gofiber.io>
2022-02-03 15:09:46 +01:00
Aliqyan Tapia 39a503cc1d
🚀 SaveFile to default External Storage (#1557)
* fiber change

* reference correct storage in SaveFile

* seperate logic to new function

* Change storage defination style, fix tests on go1.14

* Add unit test.

Co-authored-by: Alex Bakker <abakks@hotmail.com>
Co-authored-by: M. Efe Çetin <efectn@protonmail.com>
2022-02-03 14:09:11 +01:00
M. Efe Çetin a51ec9bc69
🔥 Feature: Add ReqHeaderParser. (#1721)
* Add ReqHeaderParser.

* Cleanup and tidy up parser codes.

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

* Add benchmark for ReqHeaderParser.

* Revert collectVisitAllData

Co-authored-by: RW <rene@gofiber.io>
2022-01-24 20:41:37 +01:00
kingdevnl 82d1039416
feature: Pass all locals to ctx.Render (#1693)
* feature: Pass all locals to ctx.Render

* add test case for render using locals

* Added option PassLocalsToViews to enable pass locals to render

The option PassLocalsToViews is set to disabled by default

* Added a check to see if the ctx bind already contains the value

* Added a test for ctx render with locals and binds.
2022-01-24 08:29:46 +01:00