* 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
* 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
* 🐛 Fix: Expiration time in cache middleware
* Custom expiration time using ExpirationGenerator is also functional
now instead of default Expiration only
* 🚨 Improve Test_CustomExpiration
* - stabilization of the tests
- speed up the cache tests
- fix race conditions in client and client tests
Co-authored-by: wernerr <rene@gofiber.io>
* 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>
* ✨ Cache middleware: Store e2e headers.
As defined in RFC2616 - section-13.5.1, shared caches MUST
store end-to-end headers from backend response and MUST be
transmitted in any response formed from a cache entry.
This commit ensures a stronger consistency between responses
served from the handlers & from the cache middleware.
* ✨ Cache middleware: Add flag for e2e headers.
Set flag to prevent e2e headers caching to
be the default behavior of the cache middleware.
This would otherwise change quite a lot the
experience for cache middleware current users.
* ✨ Cache middleware: Add Benchmark for additionalHeaders feature.
* ✨ Cache middleware: Rename E2Eheaders into StoreResponseHeaders.
E2E is an acronym commonly associated with test.
While in the present case it refers to end-to-end
HTTP headers (by opposition to hop-by-hop), this
still remains confusing. This commits renames it
to a more generic name.
* ✨ Cache middleware: Update README
* ✨ Cache middleware: Move map instanciation.
This will prevent an extra memory allocation for users
not interested in this feature.
* ✨ Cache middleware: Prevent memory allocation when StoreResponseHeaders is disabled.
* ✨ Cache middleware: Store e2e headers. #1807
- use set instead of add for the headers
- copy value from the headers -> prevent problems with mutable values
Co-authored-by: wernerr <rene@gofiber.io>
* added HEAD method to caching
* changed key due to head and get sharing same key
* Update cache.go
- add a improvement task for later
* Update cache.go
correct comment
Co-authored-by: Jesse Quinn <jesse.quinn@zpesystems.com>
Co-authored-by: RW <rene@gofiber.io>
* 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>
* add cache header to show cache status
* update default CacheHeader to X-Cache
* add CacheHeader test
* Update cache_test.go
use constants in test
Co-authored-by: RW <rene@gofiber.io>