Releases: gofiber/fiber
v2.43.0
❗ BreakingChange
- Drop go 1.16 support & update to fasthttp 1.45.0 (#2374)
Due to the fact that fasthttp, which fiber is based on in release 1.45.0, does not support go version 1.16 anymore, we had to remove it from our package as well.
🚀 New
- Allow preloaded certs with prefork (#2351)
https://docs.gofiber.io/api/app#listentlswithcertificate
https://docs.gofiber.io/api/app#listenmutualtlswithcertificate
app.ListenTLSWithCertificate(":443", cert);
app.ListenMutualTLSWithCertificate(":443", cert, clientCertPool);
- Add queryBool parser (#2329)
https://docs.gofiber.io/api/ctx#querybool
// GET http://example.com/?name=alex&want_pizza=false&id=
app.Get("/", func(c *fiber.Ctx) error {
c.QueryBool("want_pizza") // false
c.QueryBool("want_pizza", true) // false
c.QueryBool("alex") // true
c.QueryBool("alex", false) // false
c.QueryBool("id") // true
c.QueryBool("id", false) // false
// ...
})
- Add queryFloat parser (#2328)
https://docs.gofiber.io/api/ctx#queryfloat
// GET http://example.com/?name=alex&amount=32.23&id=
app.Get("/", func(c *fiber.Ctx) error {
c.QueryFloat("amount") // 32.23
c.QueryFloat("amount", 3) // 32.23
c.QueryFloat("name", 1) // 1
c.QueryFloat("name") // 0
c.QueryFloat("id", 3) // 3
// ...
})
- Middleware/session: SessionOnly when cookie.Expires is 0 (#2152)
https://docs.gofiber.io/api/middleware/session
session.New(session.Config{
// Decides whether cookie should last for only the browser sesison.
CookieSessionOnly: true,
})
- Middleware/proxy: Add DoRedirects, DoTimeout and DoDeadline to Proxy middleware (#2332)
https://docs.gofiber.io/api/middleware/proxy
// DoRedirects performs the given http request and fills the given http response while following up to maxRedirectsCount redirects.
func DoRedirects(c *fiber.Ctx, addr string, maxRedirectsCount int, clients ...*fasthttp.Client) error
// DoDeadline performs the given request and waits for response until the given deadline.
func DoDeadline(c *fiber.Ctx, addr string, deadline time.Time, clients ...*fasthttp.Client) error
// DoTimeout performs the given request and waits for response during the given timeout duration.
func DoTimeout(c *fiber.Ctx, addr string, timeout time.Duration, clients ...*fasthttp.Client) error
🧹 Updates
- Get mime fallback (#2340)
- Middleware/requestid: don't call "Generator" func on existing request ID header (#2371)
- Middleware/basicauth: Optimize Basic auth alloc (#2333)
🐛 Fixes
- Middleware/requestid: Config.ContextKey is interface{} (#2369)
- Middleware/cors: Fix cors * behavior #2338 (#2339)
📚 Documentation
- Use proper discord invitation link (#2382)
- Corrected coding typos in MountPath docs section (#2379)
- Fix typo in docs (#2357)
- Fix(docs): add missing comma (#2353)
- Fix all inaccessible links in docs (#2349)
- Automated synchronization with
gofiber/docs
(#2344)
Full Changelog: v2.42.0...v2.43.0
Thank you @CaioAugustoo, @HHongSeungWoo, @IwateKyle, @Rorke76753, @Skyenought, @UtopiaGitHub, @benjajaja, @derkan, @dozheiny, @efectn, @gaby, @leonklingele, @lublak, @msaf1980, @ryand67 and @yvestumushimire for making this update possible.
v2.42.0
🚀 New
- Ctx: Context method for query paramters with numbers (#2306)
https://docs.gofiber.io/api/ctx#queryint
// GET http://example.com/?id=5555
app.Get("/", func(c *fiber.Ctx) error {
c.QueryInt("id", 1) // 5555
// ...
})
- Middleware/earlydata: Add earlydata middleware (v2 backport) (#2314)
https://docs.gofiber.io/api/middleware/earlydata
adds support for TLS 1.3's early data ("0-RTT") feature
app.Use(earlydata.New())
- Middleware/idempotency: Add idempotency middleware (v2 backport) (#2288)
https://docs.gofiber.io/api/middleware/idempotency
allows for fault-tolerant APIs where duplicate requests — for example due to networking issues on the client-side — do not erroneously cause the same action performed multiple times on the server-side.
app.Use(idempotency.New(idempotency.Config{
Lifetime: 42 * time.Minute,
// ...
}))
- Middleware/proxy: Add forward from domain (#2323)
https://docs.gofiber.io/api/middleware/proxy
// If you want to forward with a specific domain. You have to use proxy.DomainForward.
app.Get("/payments", proxy.DomainForward("docs.gofiber.io", "http://localhost:8000"))
// Or this way if the balancer is using https and the destination server is only using http.
app.Use(proxy.BalancerForward([]string{
"http://localhost:3001",
"http://localhost:3002",
"http://localhost:3003",
}))
🧹 Updates/CI
- Middleware/favicon: Add url for favicon middleware, for correct handling different of… (#2231)
https://docs.gofiber.io/api/middleware/favicon - CI: Add go 1.20 to ci and readmes (#2322)
- CI: Add and apply more stricter golangci-lint linting rules (#2286)
- CI: Added testcases and minor algorithm improvment (#2308)
- CI: Make most tests parallel (#2299)
- CI: Bump github.com/valyala/fasthttp from 1.43.0 to 1.44.0 (#2292)
🐛 Fixes
- CI: Fix issues introduced in linting PR (#2319)
- Use
app.getString, app.GetBytes
instead ofutils.UnsafeString, utils.UnsafeBytes
inctx.go
(#2297) - Os: Fix gopsutil compilation (#2298)
- Middleware/logger: logger color output (#2296)
📚 Documentation
- Rework Chinese (Taiwan) translation of documentation (#2310)
- Correct the figure link in READMEs (#2312)
- Remove the redundant space beside a comma (#2309)
- Add discord channel link (ID) (#2303)
- Middleware/filesystem: fix statik filesystem middleware example typo (#2302)
- Middleware/filesystem: clean duplicated namespace for example (#2313)
- Middleware/limiter: fix alignment in limiter example (#2283)
- Middleware/encryptcookie: Openssl rand -base64 32 hints (#2316)
Full Changelog: v2.41.0...v2.42.0
Thank you @0xdeface, @100gle, @TwiN, @cloudwindy, @dozheiny, @efectn, @leonklingele, @meehow, @pan93412, @rendiputra and @rhabichl for making this update possible.
v2.41.0
🚀 New
- Add ShutdownWithTimeout function (#2228)
https://docs.gofiber.io/api/app#server-shutdown - Match function (#2142)
https://pkg.go.dev/github.com/gofiber/fiber/v2#RoutePatternMatch
🧹 Updates
- Latency use lowest time unit in logger middleware (#2261)
- Add more detail error message in serverErrorHandler (#2267)
- Use fasthttp.AddMissingPort (#2268)
- Set byteSent log to 0 when use SetBodyStreamWriter (#2239)
- Unintended overwritten bind variables (#2240)
- Bump github.com/valyala/fasthttp from 1.41.0 to 1.43.0 (#2237, #2245)
- Bump github.com/mattn/go-isatty from 0.0.16 to 0.0.17 (#2279)
🐛 Fixes
- Fix some warnings, go-ole on mac os (#2280)
- Properly handle error of "net.ParseCIDR" in "(*App).handleTrustedProxy" (#2243)
- Fix regex constraints that contain comma (#2256)
- Unintended overwritten bind variables (#2240)
📚 Documentation
- Fix ci badge errors (#2282)
- Replace
1.14
with1.16
in READMEs (#2265) - Update docstring for FormValue() (#2262)
- Added Ukrainian README translation (#2249)
- middleware/requestid: mention that the default UUID generator exposes the number of requests made to the server (#2241)
- middleware/filesystem does not handle url encoded values on it's own (#2247)
Full Changelog: v2.40.1...v2.41.0
Thank you @AngelVI13, @Simerax, @cwinters8, @efectn, @jfcg, @leonklingele, @li-jin-gou, @pjebs, @shuuji3 and @v1def for making this update possible.
v2.40.1
v2.40.0
❗ BreakingChange
- Bump github.com/valyala/fasthttp from 1.40.0 to 1.41.0 (#2171)
- Deprecate: go 1.14 & go 1.15 support deprecation (#2172)
Due to the fact that fasthttp, which fiber is based on in release 1.41.0, does not support go versions 1.14 & 1.15 anymore, we had to remove them from our package as well.
🚀 New
- Register custom methods (#2107)
https://docs.gofiber.io/api/fiber#config
// now you can add your own custom methods
app := fiber.New(fiber.Config{
RequestMethods: append(fiber.DefaultMethods, "LOAD", "TEST"),
})
app.Add("LOAD", "/hello", func(c *fiber.Ctx) error {
return c.SendString("Hello, World 👋!")
})
- Add multiple-prefix support to app.Use() and group.Use() (#2205)
https://docs.gofiber.io/api/app#route-handlers - More like Express
// declaration of multiple paths for the ".Use" method as in express is now possible
app.Use([]string{"/john", "/doe"}, func(c *Ctx) error {
return c.SendString(c.Path())
})
- Allow optional params with route constraints (#2179)
https://docs.gofiber.io/guide/routing#constraints
app.Get("/:userId<int>?", func(c *fiber.Ctx) error {
return c.SendString(c.Params("userId"))
})
// curl -X GET http://localhost:3000/42
// 42
// curl -X GET http://localhost:3000/
//
- Improve mounting behavior (#2120)
https://docs.gofiber.io/api/app#mount https://docs.gofiber.io/api/app#mountpath
app := fiber.New()
micro := fiber.New()
// order when registering the mounted apps no longer plays a role
app.Mount("/john", micro)
// before there was problem when after mounting routes were registered
micro.Get("/doe", func(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
})
// output of the mount path possible
micro.MountPath() // "/john"
- Middleware/pprof: Add URL prefix to pprof middleware (#2194)
https://docs.gofiber.io/api/middleware/pprof
// In systems where you have multiple ingress endpoints, it is common to add a URL prefix, like so:
app.Use(pprof.New(pprof.Config{Prefix: "/endpoint-prefix"}))
- Middleware/logger: Add customTags in Config (#2188, #2224, #2225)
https://docs.gofiber.io/api/middleware/logger#add-custom-tags
app.Use(logger.New(logger.Config{
Format: "[${time}] ${status} - ${latency} ${method} ${randomNumber} ${path}\n",
CustomTags: map[string]logger.LogFunc{
// possibility to adapt or overwrite existing tags
logger.TagMethod: func(output logger.Buffer, c *fiber.Ctx, data *logger.Data, extraParam string) (int, error) {
return output.WriteString(utils.ToLower(c.Method()))
},
// own tags can be registered
"randomNumber": func(output logger.Buffer, c *fiber.Ctx, data *logger.Data, extraParam string) (int, error) {
return output.WriteString(strconv.FormatInt(rand.Int63n(100), 10))
},
},
}))
// [17:15:17] 200 - 0s get 10 /test
// [17:15:17] 200 - 0s get 51 /test
- Middleware/logger: Add callback function (#2219)
https://docs.gofiber.io/api/middleware/logger#callback-after-log-is-written
app.Use(logger.New(logger.Config{
// is triggered when the handlers has been processed
Done: func(c *fiber.Ctx, logString []byte) {
// allows saving the logging string to other sources
if c.Response().StatusCode() != fiber.StatusOK {
reporter.SendToSlack(logString)
}
},
}))
🧹 Updates
- Track Configured Values (#2221)
- Ctx: simplify Protocol() (#2217)
- Ctx: make Secure() also report whether a secure connection was established to a trusted proxy (#2215)
- Ctx: update Locals function to accept interface{} key (#2144)
- Utils: reduce diff to external utils package (#2206)
- Utils: Update HTTP status codes (#2203)
- Utils: Replace UnsafeBytes util with suggested way (#2204)
- Fix and optimize memory storage (#2207)
- Leverage runtime/debug to print the full stack trace info (#2183)
- Ci: add check-latest param in vulncheck.yml (#2197)
- Ci: replace snyk with govulncheck (#2178)
🐛 Fixes
- Fix naming of routes inside groups (#2199)
📚 Documentation
- Update list of third-party library licenses (#2211)
- Update README_zh-CN.md (#2186)
- Add korean translate in Installation section (#2213)
- Comment typo (#2173)
- Cache readme and docs update (#2169)
Full Changelog: v2.39.0...v2.40.0
Thank you @Skyenought, @calebcase, @efectn, @gandaldf, @gmlewis, @jamestiotio, @leonklingele, @li-jin-gou, @marcmartin13, @panjf2000, @pjebs, @rafimuhammad01 and @thor-son for making this update possible.
v2.39.0
🚀 New
- Middleware/cache: Cache-Control: no-cache/no-store (#2159)
https://docs.gofiber.io/api/middleware/cache - Middleware/proxy: support to set client (#2117)
https://docs.gofiber.io/api/middleware/proxy - Add GetRoutes (#2112)
https://docs.gofiber.io/api/app#getroutes - Static: add CacheControl to Static config (#2140)
https://docs.gofiber.io/api/app#static
🧹 Updates
- Improve memory storage (#2162)
- Make IP validation 2x faster (#2158)
- Switch to text/javascript as per RFC9239 (#2146)
- Test: add nil jsonDecoder test case (#2139)
- Utils: update mime extensions (#2133)
🐛 Fixes
- Unhandled errors and update code comments to help the IDEs (#2128)
- Multi-byte AppName displays confusion (#2148)
- Query string parameter pass to fiber context (#2164)
- Handle multiple X-Forwarded header (#2154)
- Middleware/proxy - solve data race in middleware/proxy's test (#2153)
- Middleware/session - Reset d.Data instead of deleting keys in it (#2156)
- Agent: agent.Struct fails to unmarshal response since 2.33.0 #2134 (#2137)
📚 Documentation
- Update logger's comment (#2157)
- Update ReadmeID (#2150)
- Add doc about usage of CSRF and EncryptCookie middlewares. (#2141)
- Update language count (#2131)
- Typos (#2127)
Full Changelog: v2.38.1...v2.39.0
Thank you @Kamandlou, @Yureien, @efectn, @floxydio, @fufuok, @joseroberto, @leonklingele, @li-jin-gou, @marcmartin13, @nathanfaucett, @sadfun, @supakornbabe, @unickorn and @xbt573 for making this update possible.
v2.38.1
🚀 New
- Middleware/cache: Add methods configuration (#2081)
https://docs.gofiber.io/api/middleware/cache
🧹 Updates
- Middleware/timeout: Add timeout context middleware (#2090)
https://docs.gofiber.io/api/middleware/timeout - Fix linter errors for tests (#2102)
- Upgrade go version to 1.19 in go.mod (#2103)
- Remove redundant parentheses and update comments (#2082)
- Update code comment for helping IDEs (#2095)
- Update code comments for helping IDEs and fix unhandled error in test (#2099)
🐛 Fixes
- Test: fix Test_Ctx_ParamParser route param (#2119)
- SchemaPasers: Same struct parse param failed (#2101)
- Fix
ctx.SendStream(io.Reader)
huge memory usage (#2091)
📚 Documentation
Full Changelog: v2.37.1...v2.38.1
Thank you @Kamandlou, @dayuoba, @efectn, @hakankutluay, @li-jin-gou, @nnnkkk7 and @trim21 for making this update possible.
v2.37.1
🧹 Updates
- Bump github.com/valyala/fasthttp from 1.39.0 to 1.40.0 (#2075)
- Unhandled errors in app_test.go (#2071)
- Unhandled error in hooks test (#2070)
🐛 Fixes
- Constraints when to use multiple params (#2077)
- Unhandle in strictmode (#2055)
- EnvVar middleware parses base64 incorrectly (#2069)
Full Changelog: v2.37.0...v2.37.1
Thank you @Kamandlou, @efectn, @fufuok and @wangjq4214 for making this update possible.
v2.37.0
🚀 New
- Route constraints (#1998)
https://docs.gofiber.io/guide/routing#constraints - Add envvar expose middleware (#2054)
https://docs.gofiber.io/api/middleware/envvar - Add XML to context. (#2003)
https://docs.gofiber.io/api/ctx#xml
https://docs.gofiber.io/api/fiber - XMLEncoder - Middleware/csrf custom extractor (#2052)
https://docs.gofiber.io/api/middleware/csrf - Tls.ClientHelloInfo in Ctx (#2011)
https://docs.gofiber.io/api/ctx#clienthelloinfo
🧹 Updates
- Remove prefork support from custom listeners (#2060)
- Make IP() and IPs() more reliable (#2020)
- Bump github.com/valyala/fasthttp from 1.38.0 to 1.39.0 (#2017)
- Add go 1.19 to tests (#1994)
- Add black colors to default overriding function (#1993)
🧹 Cleanup
- Unhandled errors in helpers_test.go (#2058)
- Unhandled error in
common_linux.go
(#2056) - Handle file error on closing (#2050)
- Unhandled error in cache package tests (#2049)
- Unhandled errors and remove unused parameter (#2061)
- Unhandled errors in tests (#2048)
🐛 Fixes
- Fix csrf middleware behavior with header key lookup (#2063)
- Fix regex constraints (#2059)
- Fix route constraints problems (#2033)
- Make tlsHandler public to use it with Listener (#2034)
- Case sensitivity for parameters in GetRouteURL (#2010)
- Client: fix
Agent
use after free (#2037) - Middleware/monitor - fix ignore custom settings (#2024)
- Fix proxy overwrote the wrong scheme (#2004)
- Fix infinitely
app.Test
(#1997) - Fix gopsutil when compiling for bsd (#1995)
📚 Documentation
- Make Hooks public (#2015)
- Gofmt & add missing copyright texts (#2013)
- Change support claim up to go 1.19 (#2043)
- Update Spanish readme (#2064)
- Update Italian readme (#2042)
- Update README.md (#2023)
Thank you @efectn, @Maxi-Mega, @trim21, @GalvinGao, @Kamandlou, @gbolo, @micziz, @mstrYoda, @sixcolors, @solrac97gr, @thomasdseao, @tusharxoxoxo and @wangjq4214 for making this update possible.
v2.37.0-rc.1
🚀 New
🧹 Updates
- Bump github.com/valyala/fasthttp from 1.38.0 to 1.39.0 (#2017)
- Add go 1.19 to tests (#1994)
- Add black colors to default overriding function (#1993)
🐛 Fixes
- Fix proxy overwrote the wrong scheme (#2004)
- Fix infinitely
app.Test
(#1997) - Fix gopsutil when compiling for bsd (#1995)
📚 Documentation
Thank you @Maxi-Mega, @trim21, @efectn and @wangjq4214 for making this update possible.