v1.8.4
Some old deprecated functions are now removed and template engines are moved to a separate middleware .
🔥 New
- Static struct can be used to tweak settings for serving static files https://fiber.wiki/application#static
app.Static("/", "./static", fiber.Static{
Compress: true, // Optional, default: false
ByteRange: true, // Optional, default: false
Browse: true, // Optional, default: false
Index: "john.html" // Optional, default: "index.html",
})
🧹 Updates
- app.Static(prefix, root string, config ...Static)
- c.Method(
override ...string
) - c.Path(
override ...string
) TemplateEngine
now takes infunc(raw string, bind interface{}) (string, error)
for custom template engines see https://fiber.wiki/middleware#templateapp.Test(req, ms ...int)
Add optional timeout https://fiber.wiki/application#test (#236)SameSite
got added to Cookie https://fiber.wiki/context#cookie ( #233)
🩹 Fixes
- Serve index.html on root paths using Static #222 (comment)
1.11.x, 1.12.x, 1.13.x, 1.14.x
Go version are now also tested- Internal optimizations / clean-up
- Removed unused dependencies
- Static case sensitive mis matches #227
- Static Update file/folder changes #221
- Static Fix iconfont files #222 (comment)
- Add partial comments to all functions for faster development
- Remove unused
*Conn
from*Ctx
struct
🗑️ Removed
engine
argument inapp.Render()
https://fiber.wiki/context#rendermiddleware
from Fiber package -> https://fiber.wiki/middlewareapp.WebSocket
-> https://fiber.wiki/middleware#websocketapp.Recover
-> https://fiber.wiki/middleware#recoverSettings.Compression
-> https://fiber.wiki/middleware#compression
🧬 Middleware
template
engines https://fiber.wiki/middleware#template
index.mustache
<html>
<head>
<title>Template Demo</title>
</head>
<body>
Hi, my name is {{{name}}} and im {{{age}}} years old
</body>
</html>
server.go
package main
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
)
func main() {
app := fiber.New()
app.Settings.TemplateEngine = template.Mustache()
app.Get("/", func(c *fiber.Ctx) {
bind := fiber.Map{
"name": "John",
"age": "35",
}
if err := c.Render("./index.mustache", bind); err != nil {
panic(err)
}
})
app.Listen(3000)
}