v1.10.0
Dear 🐻 Gophers,
Fiber v1.10.0
is finally released and it has some important changes we would like to share with you.
⚠️ Breaking Changes
- All routes will return the registered
Route
metadata instead ofApp
, chaining methods won't be possible anymore. - All template settings are replaced by the new
ctx.Settings.Templates
interface. See our updated template middleware for examples with support for8
template engines.
📚 Show syntax
type Engine struct {
templates *template.Template
}
func (e *Engine) Render(w io.Writer, name string, data interface{}) error {
return e.templates.ExecuteTemplate(w, name, data)
}
func main() {
app := fiber.New()
engine := &Engine{
// ./views/index.html
// <h1>{{.Title}}</h1>
templates: template.Must(template.ParseGlob("./views/*.html")),
}
app.Settings.Template = engine
app.Get("/hello", func(c *fiber.Ctx) {
c.Render("index", fiber.Map{
"Title": "Hello, World!",
})
})
}
ctx.Body(key ...string)
Accessing form data viaBody
is deprecated, please usectx.FormValue(key string)
instead.ctx.Cookies(key ...string)
To get the rawCookie
header, please usectx.Get("Cookies")
instead.
🔥 New
- Handler type has been added
- app.Add register handlers with a HTTP method input:
app.Add("GET", "/foo", handler)
. - app.Settings.Templates is the interface that wraps the Render function #331.
- app.Settings.DisableHeaderNormalizing Disable normalization:
conteNT-tYPE -> Content-Type
- ctx.Context() returns context.Context that carries a deadline, a cancellation signal, and other values across API boundaries. #383
🩹 Fixes
- Exact param keys in request paths are now matched as static paths #405
c.Params()
now accepting case sensitive values and keys #392- Cookies
SameSite
attribute defaults toLax
if not set c.Append()
does not append duplicates anymore on case-sensitive valuesc.SendFile("./404.html")
would overwrite previous status codes, this has been fix. #391app.Test
Would throw anEOF
error if you do not provide aContent-Length
header when passing a bodyio.Reader
with NewRequest. This is not necessary anymore, it will add the header for you if not provided.ctx.Protocol()
also checks the"X-Forwarded-Protocol"
,"X-Forwarded-Ssl"
and"X-Url-Scheme"
headers
🧹 Updates
- app.Use & app.Group now supports
/:params
&/:optionals?
inside the prefix path. - Fiber docs are now fully translated in Russian & Chinese
- Add new supporters to README's
- Update template examples in README's
- Add
./public
to Static examples in README's #411 - Add new media articles to README's Improve performance & web-based authentication
- With the help of @ReneWerner87 we produce zero garbage on matching and dispatching incoming requests. The only heap allocations that are made, is by building the key-value pairs for path parameters. If the requested route contains no parameters, not a single allocation is necessary.
🧬 Official Middlewares
- gofiber/utils
v0.0.3
- gofiber/logger
v0.1.1
- gofiber/session
v1.1.0
- gofiber/template
v1.3.0
- gofiber/websocket
v0.2.1