github gofiber/fiber v1.10.0

latest releases: v3.0.0-beta.2, v2.52.4, v2.52.3...
3 years ago

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 of App, 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 for 8 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!",
		})
	})
}

๐Ÿ”ฅ New


๐Ÿฉน 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 to Lax if not set
  • c.Append() does not append duplicates anymore on case-sensitive values
  • c.SendFile("./404.html") would overwrite previous status codes, this has been fix. #391
  • app.Test Would throw an EOF error if you do not provide a Content-Length header when passing a body io.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


๐ŸŒฑ Third Party Middlewares

Don't miss a new fiber release

NewReleases is sending notifications on new releases.