* ✨ 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.
* 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>
* 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>
- 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
* 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>
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.