โก๏ธ Express inspired web framework written in Go
io/fs
(#2027)[]byte
support to utils.EqualFold
(#2029)utils.Trim*
because stdlib has same performance in go1.19 (#2030)Full Changelog: https://github.com/gofiber/fiber/compare/v2.52.4...v3.0.0-beta.2
Thank you @efectn, @Behzad-Khokher, @the-hotmann, @gozeloglu, @trim21, @wangjq4214, @KrisCarr, @pjebs, @balcieren, @leonklingele, @sixcolors, @nickajacks1, @gandaldf, @StrawHatHacker, @ryanbekhen, @theleeeo, @nnnkkk7, @canks69, @asyslinux, @brunodmartins, @gaby, @linogomez, @Fenny, @grivera64, @ReneWerner87, @luk3skyw4lker, @dreamscached, @emirhansirkeci, @sebytza23, @techerfan, @racerole, @negrel, @devhsoj, @dozheiny for making this update possible.
Full Changelog: https://github.com/gofiber/fiber/compare/v2.52.3...v2.52.4
Full Changelog: https://github.com/gofiber/fiber/compare/v2.52.2...v2.52.3
Full Changelog: https://github.com/gofiber/fiber/compare/v2.52.1...v2.52.2
Full Changelog: https://github.com/gofiber/fiber/compare/v2.52.0...v2.52.1
Thank you @luk3skyw4lker, @CAEL0, @grivera64, @gaby and @sixcolors for making this update possible.
// Direct usage with default config
app.Use(healthcheck.New())
// Or extend your config for customization
app.Use(healthcheck.New(healthcheck.Config{
LivenessEndpoint: "/live",
LivenessProbe: func(c *fiber.Ctx) bool {
return true
},
ReadinessEndpoint: "/ready",
ReadinessProbe: func(c *fiber.Ctx) bool {
return serviceA.Ready() && serviceB.Ready() && ...
},
}))
Full Changelog: https://github.com/gofiber/fiber/compare/v2.51.0...v2.52.0
Thank you @MehmetFiratKomurcu, @benjajaja, @brunodmartins, @gilwo, @iredmail, @itswcg, @luk3skyw4lker, @muhammadkholidb, @nickajacks1, @sixcolors and @tokelo-12 for making this update possible.
// Consideration of parameters in the accepted headers
// Accept: text/plain, application/json; version=1; foo=bar
app.Get("/", func(c *fiber.Ctx) error {
// Extra parameters in the accept are ignored
c.Accepts("text/plain;format=flowed") // "text/plain;format=flowed"
// An offer must contain all parameters present in the Accept type
c.Accepts("application/json") // ""
// Parameter order and capitalization does not matter. Quotes on values are stripped.
c.Accepts(`application/json;foo="bar";VERSION=1`) // "application/json;foo="bar";VERSION=1"
})
// Passing a custom json type
ctx.JSON(fiber.Map{
"type": "https://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"status": 403,
"detail": "Your current balance is 30, but that costs 50.",
"instance": "/account/12345/msgs/abc",
}, fiber.)
Full Changelog: https://github.com/gofiber/fiber/compare/v2.50.0...v2.51.0
Thank you @BandhiyaHardik, @database64128, @efectn, @moritz157, @nickajacks1, @rhburt and @sixcolors for making this update possible.
To allow single and list values under headers according to the rfc standard
- func (c *Ctx) GetReqHeaders() map[string]string
+ func (c *Ctx) GetReqHeaders() map[string][]string
- func (c *Ctx) GetRespHeaders() map[string]string
+ func (c *Ctx) GetRespHeaders() map[string][]string
https://docs.gofiber.io/api/middleware/csrf
๐ Improvements to the CSRF middleware:
SingleUseToken
configuration option.Session
and SessionKey
configuration options.Session
.Thank you @sixcolors
// Field names should start with an uppercase letter
type Person struct {
Name string `cookie:"name"`
Age int `cookie:"age"`
Job bool `cookie:"job"`
}
// Example route
app.Get("/", func(c *fiber.Ctx) error {
p := new(Person)
// This method is similar to BodyParser, but for cookie parameters
if err := c.CookieParser(p); err != nil {
return err
}
log.Println(p.Name) // Joseph
log.Println(p.Age) // 23
log.Println(p.Job) // true
})
// To disable caching completely, pass MaxAge value negative. It will set the Access-Control-Max-Age header 0.
app.Use(cors.New(cors.Config{MaxAge: -1}))
// Provide more flexibility in session management, especially in scenarios like repeated user logins
func (s *Session) Reset() error
Example usage:
// Initialize default config
// This stores all of your app's sessions
store := session.New()
app.Post("/login", func(c *fiber.Ctx) error {
// Get session from storage
sess, err := store.Get(c)
if err != nil {
panic(err)
}
// ... validate login ...
// Check if the session is fresh
if !sess.Fresh() {
// If the session is not fresh, reset it
if err := sess.Reset(); err != nil {
panic(err)
}
}
// Set new session data
sess.Set("user_id", user.ID)
// Save session
if err := sess.Save(); err != nil {
panic(err)
}
return c.SendString(fmt.Sprintf("Welcome %v", user.ID))
})
// Provide more control over individual session management, especially in scenarios
// like administrator-enforced user logout or user-initiated logout from a specific device session
func (s *Store) Delete(id string) error
Example usage:
app.Post("/admin/session/:id/logout", func(c *fiber.Ctx) error {
// Get session id from request
sessionID := c.Params("id")
// Delete the session
if err := store.Delete(sessionID); err != nil {
return c.Status(500).SendString(err.Error())
}
return c.SendString("Logout successful")
})
Full Changelog: https://github.com/gofiber/fiber/compare/v2.49.2...v2.50.0
Thank you @KaptinLin, @Skyenought, @cuipeiyu, @dairlair, @efectn, @gaby, @geerew, @huykn, @jimmyl02, @joey1123455, @joshlarsen, @jscappini, @peczenyj and @sixcolors for making this update possible.
Full Changelog: https://github.com/gofiber/fiber/compare/v2.49.1...v2.49.2
Thank you @11-aryan and @AKARSHITJOSHI for making this update possible.
Full Changelog: https://github.com/gofiber/fiber/compare/v2.49.0...v2.49.1
Thank you @KompocikDot, @LimJiAn and @gaby for making this update possible.