1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-21 06:53:05 +00:00

187 Commits

Author SHA1 Message Date
Muhammed Efe Çetin
4105b008c2
Merge remote-tracking branch 'origin/master' into v3-beta 2022-08-19 14:33:31 +03:00
M. Efe Çetin
41159296f3
v3: revert " v3 (feature): use any as default Message type of Error struct (#1925)" (#2000)
Revert " v3 (feature): use any as default Message type of Error struct (#1925)"
2022-08-08 08:21:00 +02:00
M. Efe Çetin
adcb1f2bf1
v3: fix benchmark results (#1982)
* v3: fix benchmark results

* v3: fix benchmark results

* Fix Benchmark_Router_Github_API

* reduce duplicated tests run actions

* reduce duplicated tests run actions

* fix some benchmarks

Co-authored-by: wernerr <rene@gofiber.io>
2022-08-07 14:53:01 +03:00
M. Efe Çetin
a458bd344c
v3 (feature): convert fiber.Ctx type to interface (#1928)
*  v3: convert fiber.Ctx type to interface

* update ctx methods

* add new methods to customize ctx, fix some problems

* update comments.

* fix something
2022-07-13 07:48:29 +02:00
M. Efe Çetin
e35a594cf1
v3 (feature): use any as default Message type of Error struct (#1925)
*  v3: use any as default Message type of Error struct.

*  v3: use any as default Message type of Error struct.

*  v3: use any as default Message type of Error struct.

*  v3: use any as default Message type of Error struct.
2022-06-12 18:37:23 +02:00
Muhammed Efe Çetin
edd89de2d6
v3: remove deprecations 2022-05-31 17:50:31 +03:00
Muhammed Efe Çetin
c7f45ec38e
v3: replace interface{}s by any 2022-05-31 17:41:38 +03:00
Muhammed Efe Çetin
1188144d78
🎉 v3: init 2022-05-31 17:35:49 +03: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
akp
e974c6793f
RFC: Return an instance of *fiber.Error when no handler found (#1847)
* Return an instance of `*fiber.Error` when no handler found

When a handler cannot be found for a given path, previously Fiber
would construct a plaintext response that cannot be modified.

This commit switches to returning a new instance of `*fiber.Error`
with identical error message so that users can customise the look
of their 404 pages.

Signed-off-by: AKP <tom@tdpain.net>

* Fix `Test_App_Next_Method`

This test was failing as the error returned by `c.Next()` that's
required to generate the correct 404 status code was not being
passed through the middleware and being silently ignored.

Signed-off-by: AKP <tom@tdpain.net>

* Fix `Test_Logger_All`

Signed-off-by: AKP <tom@tdpain.net>

* Fix `Test_Cache_WithHeadThenGet` test

As far as I can tell, this test is meant to check that a cached
HEAD request to a given endpoint does not return the cached
content to a GET request to the same endpoint, and the test has
been altered to correctly check for this.

Signed-off-by: AKP <tom@tdpain.net>
2022-04-05 08:39:53 +02:00
M. Efe Çetin
bd20e90e6b
feature: add initial support for hooks (#1777)
* Add initial support for hooks.

* release ctx, mutex.

* Add unit tests.

* add comment lines.

* update

* update

* remove unnecessary code.

* fix race condition.

* fix gosec.

* skip error handling for onshutdown and onresponse.

* update

* separate hooks from app.go

* make hooks field private, hook struct public and Hooks() func.

* remove onreq and onres because of they can be done by middlewares.

* OnGroupName method.

* Update hooks.go

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

* handle errors for name and groupname

* fix tests.

* Update app.go

* use struct fields instead of map

* add multi-handler.

* add onGroup, make prefix field public on Group struct.

* Update hooks.go

* add newhooks method.

*  feature: add initial support for hooks

* remove ctx from hooks.

Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>
Co-authored-by: wernerr <rene@gofiber.io>
2022-03-10 08:35:15 +01:00
Serhat Şevki Dinçer
870f9427a2
Optimize App.buildTree() (#1809)
*  Optimize App.buildTree()

- Reduces reads from / writes to slices
- Reduces reads from maps
- Increases sorting speed

*  Add Benchmark_Startup_Process()
2022-03-07 19:01:30 +01:00
Lian
af10fab05b
Add direct download option when serving static files (#1729)
* enable download for app.Static


wording

* Add unit test.

Co-authored-by: Muhammed Efe Çetin <efectn@protonmail.com>
2022-02-03 14:41:45 +01:00
M. Efe Çetin
559f59f198
Add Route() method like Chi router. (#1713) 2022-01-24 16:37:28 +01:00
vecpeng
ef3a689600
🐛fix: rename handlerCount to handlersCount (#1674) 2021-12-29 10:26:50 +01:00
M. Efe Çetin
68d3b773bc
Add route naming feature. (#1650)
* Add route naming feature.

* Update basicauth_test.go

* Fix gosec issues.

* Change RoutaName -> Name

* Fix race conditions.

* Update READMEs.
2021-12-28 14:04:04 +01:00
Gusted
7b7dcf29f7
♻️ Tidy up the codebase (#1613)
* run gofmt

* add t.Helper()

* Simplify assigns

* Simplify make operation

* Remove unused field in struct

* Fix typo

* Run gofumpt ./

* Consistent spacing

* len(...) can never be negative

* Use ReplaceAll

* Simplify operation

* Remove deadcode

* Fix typo

* Tidy up `} else { if ...`

* Fix AssertEqual

* Remove t.Helper() to fix go1.14.15
2021-11-05 08:00:03 +01:00
Jose Garcia
587f3ae9df
Support for sub fiber's error handlers (#1560)
- Mounted fiber and its sub apps error handlers are now saved a new
  errorHandlers map in App
- New public App.ErrorHandler method that wraps the logic for which
  error handler to user on any given context
- Error handler match logic based on request path <=> prefix accuracy
- Typo fixes
- Tests
2021-10-05 14:03:20 +02:00
Fufu
2c6ffb7972
Fix: register static file routing with trailing slash (#1556) 2021-10-05 10:55:11 +02:00
Fufu
b94870d886
Fix: static file routing path rewrite. (#1538)
* Fix: static file routing path rewrite.

* Add: static file routing test cases.

* Update: change os.CreateTemp to ioutil.TempFile for go1.14

* Update: optimize test cases.
2021-10-01 12:51:48 +02:00
ProExpertProg
dd153adfdb
Fix route.Path on copy (#1471) 2021-08-05 07:32:05 +02:00
RW
34520e75f8
Fix - 🐛 The escape of special characters in route path does not work properly #1454 (#1462)
* Fix - 🐛 The escape of special characters in route path does not work properly #1454
2021-07-30 20:39:10 +02:00
Javad Rajabzade
7609117cec
Improved some conditions (#1386)
* simplify `u <= (1<<7)-1` to `u < (1 << 7)`

* It's not recommended to use `len` for empty string, we can check with string with ""

* It's not recommended to use `len` for empty string, we can check with string with ""

* It's not recommended to use `len` for empty string, we can check with string with ""

* It's not recommended to use `len` for empty string, we can check with string with ""

* Instead Bool comparison can using simplified bool check if !var = false checking

* Unnecessary use of fmt.Sprintf for value without format

* For check condition two value not required ! method

* nil check may not be enough for slice, better check with len

* function parameters combined

* When the form returns error information, the text content should not start with a capital letter or end with a punctuation mark

* error var invalidPath should have name of the form errFoo, It is recommended that the error variables that are part of an API should be named

* change to condition len(x), it's faster https://github.com/gofiber/fiber/pull/1386#discussion_r652369520

* Update write.go

* Update write_bytes.go

* Update store.go

Co-authored-by: RW <rene@gofiber.io>
2021-06-17 22:03:59 +02:00
Diego Sandrim
0dc67e80d2 Moves .getBytes and .getString from package variable to App instance variable, avoiding data race when creating a new App. 2021-05-05 17:24:26 -03:00
bestgopher
056c6808af
Use atomic instead of mutex when counting the route handler. (#1314)
* use atomic instead of mutex when counting

* 📒 router: fix typo error
2021-05-05 17:53:54 +02:00
Joey
e89ef1207e
Merge pull request #1130 from mlukasik-dev/master
 add Next function to app.Static config
2021-01-31 07:54:54 +01:00
unknown
c62e5f7d4d go style updates 2021-01-26 21:57:58 +03:00
ReneWerner87
42755c30e6 Accelerate start process for many routes #1081 2021-01-24 13:02:21 +01:00
Martin Lukasik
d602fc76e2 handling case when fiber.Static config is nil 2021-01-22 23:20:12 +01:00
Martin Lukasik
3a132d0b98 add Next function to app.Static config 2021-01-22 23:07:22 +01:00
ReneWerner87
b51def0bb8 🐛 UnescapePath not working #1102
Co-authored-by: Fenny <fenny@gofiber.io>
2021-01-06 13:21:54 +01:00
Kiyon
a5a50ab020 👷 Remove redundant validation of CacheDuration when checking static config 2020-12-10 15:32:06 +08:00
Fenny
0d5519fc09 expose CacheDuration in Static 2020-11-11 14:18:19 +01:00
kiyon
4c89377631 🩹 Fix #945 2020-10-21 14:50:33 +08:00
Roman
3e6dfb313b 🔥set a Cache Control header for static ressources
Right now, each static request returns the file without any cache control
header. If you are using `app.Static` to serve your assets, the
browser shouldn't cache it. This PR introduces a way to set the cache
control header (if the file was found) on the file response to set a
custom max-age to e.g. cache it 1 year.
2020-10-07 15:44:38 +02:00
Fenny
3b5997a3df 🔨 fix mount tree build
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-09-26 13:46:14 +02:00
Fenny
e414c4a83e 🗻 able to mount sub-apps 2020-09-26 11:24:25 +02:00
Fenny
ec5d20b1dc Merge remote-tracking branch 'upstream/master' 2020-09-22 12:32:43 +02:00
kiyon
dba73ea45e 🧹 pass ErrMethodNotAllowed to handler 2020-09-21 08:45:17 +08:00
Fenny
2b72fd2162 🩹 ignore trailing slash with static directories 2020-09-20 21:48:45 +02:00
ReneWerner87
c822a17c72 ☠️ Improve error handling flow
Co-authored-by: Fenny <fenny@gofiber.io>
Co-authored-by: Kiyon <kiyon@gofiber.io>
2020-09-18 20:44:00 +02:00
Fenny
2768ea2a77 🙌 make utils public
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-09-14 12:12:29 +02:00
Fenny
a3cac71ae8 🔦 move utils to internal 2020-09-14 09:09:06 +02:00
Fenny
ec5d66e7a8 v2 2020-09-13 11:20:11 +02:00
ReneWerner87
ad7f4df9a7 🦟 Fix star routes 2020-09-02 20:59:42 +02:00
ReneWerner87
2c6d7e00c4 🌵hybrid routing with tree and fast router 2020-08-10 10:54:41 +02:00
ReneWerner87
df3c48a734 🌵hybrid routing with tree and fast router 2020-08-10 10:51:38 +02:00
ReneWerner87
945b61d1c3 🌵hybrid routing with tree and fast router 2020-08-09 21:53:15 +02:00
kiyon
cf22aa2ae5 🩹 handle invalid http method 2020-07-24 22:55:57 +08:00
Fenny
396b6ddebc 🗑️ Remove pos from Route
Co-Authored-By: RW <renewerner87@googlemail.com>
Co-Authored-By: kiyon <kiyonlin@users.noreply.github.com>
2020-07-22 02:07:57 +02:00