โก๏ธ Express inspired web framework written in Go
EnableSplittingOnParsers splits the query/body/header parameters by comma when it's true (default: false).
For example, you can use it to parse multiple values from a query parameter like this: /api?foo=bar,baz == foo[]=bar&foo[]=baz
This allows the user to use //go:embed flags to load favicon data during build-time, and supply it to the middleware instead of reading the file every time the application starts.
errors.Is
instead of os.IsNotExist
(#2558)Full Changelog: https://github.com/gofiber/fiber/compare/v2.48.0...v2.49.0
Thank you @Jictyvoo, @Juneezee, @Kirari04, @LimJiAn, @PassTheMayo, @andersonmiranda-com, @bigpreshy, @efectn, @renanbastos93, @scandar, @sixcolors and @stefanb for making this update possible.
app := fiber.New(fiber.Config{
DisableStartupMessage: true,
})
app.Hooks().OnListen(func(listenData fiber.ListenData) error {
if fiber.IsChild() {
return nil
}
scheme := "http"
if data.TLS {
scheme = "https"
}
log.Println(scheme + "://" + listenData.Host + ":" + listenData.Port)
return nil
})
app.Listen(":5000")
Full Changelog: https://github.com/gofiber/fiber/compare/v2.47.0...v2.48.0
Thank you @ForAeons, @RHeynsZa, @Saman-Safaei, @Skyenought, @Z3NTL3, @andre-dasilva, @cmd777, @dozheiny, @efectn, @f1rstmehul, @gaby, @itcuihao and @mo1ein for making this update possible.
// GET /api/posts?filters.author.name=John&filters.category.name=Technology
app.Get("/", func(c *fiber.Ctx) error {
m := c.Queries()
m["filters.author.name"] // John
m["filters.category.name"] // Technology
})
// Disable colors when outputting to default format
app.Use(logger.New(logger.Config{
DisableColors: true,
}))
Full Changelog: https://github.com/gofiber/fiber/compare/v2.46.0...v2.47.0
Thank you @Kamandlou, @Satont, @Skyenought, @cmd777, @dozheiny, @efectn, @gaby, @kaazedev, @luk3skyw4lker, @obakumen, @sixcolors and @ytsruh for making this update possible.
Full Changelog: https://github.com/gofiber/fiber/compare/v2.45.0...v2.46.0
Thank you @alekseikovrigin, @efectn and @leonklingele for making this update possible.
Full Changelog: https://github.com/gofiber/fiber/compare/v2.44.0...v2.45.0
Thank you @Jamess-Lucass, @baichangda, @carmeloriolo, @kanansnote and @kousikmitra for making this update possible.
Note: Using this feature is discouraged in production and it's best practice to explicitly set CORS origins via AllowOrigins.
In this example any origin will be allowed via CORS. For example, if a browser running on http://localhost:3000 sends a request, this will be accepted and the access-control-allow-origin response header will be set to http://localhost:3000.
app.Use(cors.New(cors.Config{
AllowOriginsFunc: func(origin string) bool {
return os.Getenv("ENVIRONMENT") == "development"
},
}))
Full Changelog: https://github.com/gofiber/fiber/compare/v2.43.0...v2.44.0
Thank you @Jamess-Lucass, @ancogamer, @cmd777, @dozheiny, @eld4niz, @hakankutluay, @jcyamacho, @leonklingele and @shahriarsohan for making this update possible.
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.
app.ListenTLSWithCertificate(":443", cert);
app.ListenMutualTLSWithCertificate(":443", cert, clientCertPool);
// 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
// ...
})
// 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
// ...
})
session.New(session.Config{
// Decides whether cookie should last for only the browser sesison.
CookieSessionOnly: true,
})
// 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
gofiber/docs
(#2344)Full Changelog: https://github.com/gofiber/fiber/compare/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.
// GET http://example.com/?id=5555
app.Get("/", func(c *fiber.Ctx) error {
c.QueryInt("id", 1) // 5555
// ...
})
adds support for TLS 1.3's early data ("0-RTT") feature
app.Use(earlydata.New())
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,
// ...
}))
// 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",
}))
app.getString, app.GetBytes
instead of utils.UnsafeString, utils.UnsafeBytes
in ctx.go
(#2297)Full Changelog: https://github.com/gofiber/fiber/compare/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.
1.14
with 1.16
in READMEs (#2265)Full Changelog: https://github.com/gofiber/fiber/compare/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.
/
(#2227)Full Changelog: https://github.com/gofiber/fiber/compare/v2.40.0...v2.40.1