Small changes (#415)

* Update template examples

* Update fasthttp to v1.13.1

Co-Authored-By: Thomas van Vugt <thomasvvugt@users.noreply.github.com>

* Cookie SameSite defaults to Lax

Co-Authored-By: Thomas van Vugt <thomasvvugt@users.noreply.github.com>
Co-Authored-By: Queru <pascal@queru.net>

* Fix router bug

Co-Authored-By: RW <renewerner87@googlemail.com>

* Remove unused code

Co-Authored-By: RW <renewerner87@googlemail.com>

Co-authored-by: Thomas van Vugt <thomasvvugt@users.noreply.github.com>
Co-authored-by: Queru <pascal@queru.net>
Co-authored-by: RW <renewerner87@googlemail.com>
pull/417/head
fenny 2020-05-27 04:22:01 -04:00 committed by GitHub
parent 02b4061b44
commit f2c027e715
19 changed files with 189 additions and 247 deletions

28
.github/README.md vendored
View File

@ -121,7 +121,7 @@ These tests are performed by [TechEmpower](https://github.com/TechEmpower/Framew
- [API endpoints](https://docs.gofiber.io/context)
- [Middleware](https://docs.gofiber.io/middleware) & [Next](https://docs.gofiber.io/context#next) support
- [Rapid](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) server-side programming
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Translated in [12 other languages](https://docs.gofiber.io/)
@ -180,11 +180,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -232,35 +232,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -357,7 +353,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

View File

@ -135,7 +135,7 @@ go get -u github.com/gofiber/fiber
- [API endpoints](https://docs.gofiber.io/context)
- [Middleware](https://docs.gofiber.io/middleware) & [Next](https://docs.gofiber.io/context#next) مدعوم
- [سريع](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) server-side programming
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket دعم](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- ترجم الى [12 لغة أخرى](https://docs.gofiber.io/)
@ -201,11 +201,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -258,37 +258,34 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber يدعم وبشكل افتراضي [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
ولكن إذا كنت ترغب في استخدام محرك قالب آخر مثل [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) او [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://github.com/gofiber/template).
يمكنك استخدام [Template Middleware](https://docs.gofiber.io/middleware#template).
<div dir="ltr" >
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -406,7 +403,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_de.md vendored
View File

@ -121,7 +121,7 @@ Diese Tests wurden von [TechEmpower](https://github.com/TechEmpower/FrameworkBen
- Express [API Endpunkte](https://docs.gofiber.io/context)
- [Middleware](https://docs.gofiber.io/middleware) & [Next](https://docs.gofiber.io/context#next) Support
- [Schnelle](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) serverseitige Programmierung
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -176,11 +176,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -228,35 +228,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -353,7 +349,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_es.md vendored
View File

@ -121,7 +121,7 @@ Estas pruebas son realizadas por [TechEmpower](https://github.com/TechEmpower/Fr
- [Puntos finales de API](https://docs.gofiber.io/context) Express
- Middleware y [próximo](https://docs.gofiber.io/context#next) soporte
- Programación [rápida](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) del lado del servidor
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Disponible en [12 idiomas](https://docs.gofiber.io/)
@ -176,11 +176,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -228,35 +228,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber soporta el [Go template engine](https://golang.org/pkg/html/template/) por default.
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
Pero si deseas usar otro template engine como [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) o [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
Puedes usar nuestro [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -353,7 +349,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_fr.md vendored
View File

@ -121,7 +121,7 @@ Ces tests sont effectués par [TechEmpower](https://github.com/TechEmpower/Frame
- [API endpoints](https://docs.gofiber.io/context)
- Middleware & [Next](https://docs.gofiber.io/context#next) support
- Programmation côté serveur [rapide](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497)
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -176,11 +176,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -228,35 +228,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -353,7 +349,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

32
.github/README_he.md vendored
View File

@ -244,11 +244,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -301,40 +301,36 @@ func main() {
<summary>📚 הצג דוגמאות קוד נוספות</summary>
### מנועי תבניות
### Template engines
📖 [הגדרות](https://docs.gofiber.io/application#settings)
📖 [רנדור](https://docs.gofiber.io/context#render)
📖 [תבניות](https://docs.gofiber.io/middleware#template)
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
Fiber תומך כברירת מחדל ב[מנוע התבניות של Go](https://golang.org/pkg/html/template/).
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
אבל אם ברצונכם להשתמש במנוע תבניות אחר כמו [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) או [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
אתם יכולים להשתמש ב[Middleware של התבניות](https://docs.gofiber.io/middleware#template) שלנו.
You can use our [Template Middleware](https://github.com/gofiber/template).
<div dir="ltr">
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -446,7 +442,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_id.md vendored
View File

@ -121,7 +121,7 @@ Pengukuran ini dilakukan oleh [TechEmpower](https://github.com/TechEmpower/Frame
- Cocok untuk [API](https://docs.gofiber.io/context)
- Mendukung Middleware & [Next](https://docs.gofiber.io/context#next) seperti Express
- Kembangkan aplikasi dengan [Cepat](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497)
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -178,11 +178,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -230,35 +230,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -355,7 +351,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_ja.md vendored
View File

@ -122,7 +122,7 @@ go get -u github.com/gofiber/fiber/...
- Express [APIエンドポイント](https://docs.gofiber.io/context)
- Middlewareと[Next](https://docs.gofiber.io/context#next)のサポート
- [迅速](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497)なサーバーサイドプログラミング
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -180,11 +180,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -232,35 +232,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -357,7 +353,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_ko.md vendored
View File

@ -121,7 +121,7 @@ go get -u github.com/gofiber/fiber/...
- [API 엔드포인트](https://docs.gofiber.io/context)
- 미들웨어 & [Next](https://docs.gofiber.io/context#next) 지원
- [빠른](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) 서버 사이드 프로그래밍
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -180,11 +180,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -232,35 +232,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -357,7 +353,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

26
.github/README_nl.md vendored
View File

@ -180,11 +180,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -232,35 +232,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -357,7 +353,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_pt.md vendored
View File

@ -121,7 +121,7 @@ Esses testes são realizados pelo [TechEmpower](https://github.com/TechEmpower/F
- [API de rotas](https://docs.gofiber.io/context)
- Suporte para Middleware e [Next](https://docs.gofiber.io/context#next)
- Programação [rápida](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) de aplicações de servidor
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -176,11 +176,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -228,35 +228,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -353,7 +349,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

28
.github/README_ru.md vendored
View File

@ -121,7 +121,7 @@ go get -u github.com/gofiber/fiber
- [Эндпоинты](https://docs.gofiber.io/context), как в [API](https://docs.gofiber.io/context) Express
- [Middleware](https://docs.gofiber.io/middleware) и поддержка [Next](https://docs.gofiber.io/context#next)
- [Быстрое](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) программирование на стороне сервера
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [Поддержка WebSocket](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Документация доступна на [12 языках](https://docs.gofiber.io/)
@ -178,11 +178,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -230,35 +230,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber поддерживает [Go template engine](https://golang.org/pkg/html/template/) по умолчанию.
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
Но, вы можете использовать сторонний шаблонизатор. Например, [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) или [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
Вы можете использовать [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -355,7 +351,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

38
.github/README_tr.md vendored
View File

@ -121,7 +121,7 @@ Bu testler [TechEmpower](https://github.com/TechEmpower/FrameworkBenchmarks) ve
- [API uç noktaları](https://docs.gofiber.io/context)
- Ara katman & [Sonraki](https://docs.gofiber.io/context#next) desteği
- [Hızlı](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) sunucu taraflı programlama
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -176,11 +176,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -225,36 +225,34 @@ func main() {
<details>
<summary>📚 Daha fazla kod örneği göster</summary>
### Şablon Motorları
### Template engines
📖 [Ayarlar](https://docs.gofiber.io/application#settings)
📖 [Tasvir et(Render)](https://docs.gofiber.io/context#render)
📖 [Şablonlar](https://docs.gofiber.io/middleware#template)
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
Fiber varsayılan olarak [Go şablon motoru](https://golang.org/pkg/html/template/)'nu destekler.
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
Eğer başka bir şablon motoru kullanmak isterseniz, mesela [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) yada [pug](https://github.com/Joker/jade) gibi, bizim [Şablon Ara Katmanımızı](https://docs.gofiber.io/middleware#template) da kullanabilirsiniz.
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
//Uygulamayı başlatmadan önce şablon motorunu kurabilirsiniz:
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// YADA uygulamayı başlattıktan sonra uygun yere koyabilirsiniz:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
// OR after initiation app at any convenient location:
app.Settings.Templates = pug.New("./views", ".pug"),
// Ve şimdi, bu şekide `./views/home.tmpl` şablonunu çağırabilirsiniz:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -351,7 +349,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

View File

@ -124,7 +124,7 @@ go get -u github.com/gofiber/fiber
- Express [API端点](https://docs.gofiber.io/context)
- 中间件和[Next](https://docs.gofiber.io/context#next)支持
- [快速的](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497)服务器端编程
- [Template engines](https://docs.gofiber.io/middleware#template)
- [Template engines](https://github.com/gofiber/template)
- [WebSocket support](https://docs.gofiber.io/middleware#websocket)
- [Rate Limiter](https://docs.gofiber.io/middleware#limiter)
- Available in [12 languages](https://docs.gofiber.io/)
@ -179,11 +179,11 @@ func main() {
func main() {
app := fiber.New()
app.Static("/", "/public")
app.Static("/", "./public")
// => http://localhost:3000/js/script.js
// => http://localhost:3000/css/style.css
app.Static("/prefix", "/public")
app.Static("/prefix", "./public")
// => http://localhost:3000/prefix/js/script.js
// => http://localhost:3000/prefix/css/style.css
@ -231,35 +231,31 @@ func main() {
### Template engines
📖 [Settings](https://docs.gofiber.io/application#settings)
📖 [Template Engines](https://github.com/gofiber/template)
📖 [Render](https://docs.gofiber.io/context#render)
📖 [Template](https://docs.gofiber.io/middleware#template)
Fiber supports the default [Go template engine](https://golang.org/pkg/html/template/)
Fiber defaults to the [Go template engine](https://golang.org/pkg/html/template/) when no Template engine is set.
But if you want to use another template engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade).
If you want to template partials and a different engine like [amber](https://github.com/eknkc/amber), [handlebars](https://github.com/aymerick/raymond), [mustache](https://github.com/cbroglie/mustache) or [pug](https://github.com/Joker/jade) etc..
You can use our [Template Middleware](https://docs.gofiber.io/middleware#template).
You can use our [Template Middleware](https://github.com/gofiber/template).
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/template"
"github.com/gofiber/template/pug"
)
func main() {
// You can setup template engine before initiation app:
app := fiber.New(&fiber.Settings{
TemplateEngine: template.Mustache(),
TemplateFolder: "./views",
TemplateExtension: ".tmpl",
Templates: pug.New("./views", ".pug"),
})
// OR after initiation app at any convenient location:
app.Settings.TemplateEngine = template.Mustache()
app.Settings.TemplateFolder = "./views"
app.Settings.TemplateExtension = ".tmpl"
app.Settings.Templates = pug.New("./views", ".pug"),
// And now, you can call template `./views/home.tmpl` like this:
// And now, you can call template `./views/home.pug` like this:
app.Get("/", func(c *fiber.Ctx) {
c.Render("home", fiber.Map{
"title": "Homepage",
@ -356,7 +352,7 @@ curl -H "Origin: http://example.com" --verbose http://localhost:3000
func main() {
app := fiber.New()
app.Static("/public")
app.Static("./public")
app.Get("/demo", func(c *fiber.Ctx) {
c.Send("This is a demo!")

12
ctx.go
View File

@ -280,23 +280,17 @@ func (ctx *Ctx) Cookie(cookie *Cookie) {
fcookie.SetDomain(cookie.Domain)
fcookie.SetExpire(cookie.Expires)
fcookie.SetSecure(cookie.Secure)
if cookie.Secure {
// Secure must be paired with SameSite=None
fcookie.SetSameSite(fasthttp.CookieSameSiteNoneMode)
}
fcookie.SetHTTPOnly(cookie.HTTPOnly)
switch utils.ToLower(cookie.SameSite) {
case "lax":
fcookie.SetSameSite(fasthttp.CookieSameSiteLaxMode)
case "strict":
fcookie.SetSameSite(fasthttp.CookieSameSiteStrictMode)
case "none":
fcookie.SetSameSite(fasthttp.CookieSameSiteNoneMode)
// Secure must be paired with SameSite=None
fcookie.SetSecure(true)
default:
fcookie.SetSameSite(fasthttp.CookieSameSiteDisabled)
fcookie.SetSameSite(fasthttp.CookieSameSiteLaxMode)
}
ctx.Fasthttp.Response.Header.SetCookie(fcookie)
fasthttp.ReleaseCookie(fcookie)
}

View File

@ -272,7 +272,7 @@ func Benchmark_Ctx_Cookie(b *testing.B) {
Value: "Doe",
})
}
utils.AssertEqual(b, "John=Doe; path=/", getString(c.Fasthttp.Response.Header.Peek("Set-Cookie")))
utils.AssertEqual(b, "John=Doe; path=/; SameSite=Lax", getString(c.Fasthttp.Response.Header.Peek("Set-Cookie")))
}
// go test -run Test_Ctx_Cookie
@ -290,7 +290,7 @@ func Test_Ctx_Cookie(t *testing.T) {
Value: "john",
Expires: expire,
})
expect := "username=john; expires=" + string(httpdate) + "; path=/"
expect := "username=john; expires=" + httpdate + "; path=/; SameSite=Lax"
utils.AssertEqual(t, expect, string(ctx.Fasthttp.Response.Header.Peek(HeaderSetCookie)))
}

2
go.mod
View File

@ -6,5 +6,5 @@ require (
github.com/gofiber/utils v0.0.3
github.com/gorilla/schema v1.1.0
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/fasthttp v1.12.0
github.com/valyala/fasthttp v1.13.1
)

8
go.sum
View File

@ -1,3 +1,5 @@
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/gofiber/utils v0.0.3 h1:nNQKfZbZAGmOHqTOYplJwwOvX1Mg/NsTjfFO4/wTGrU=
github.com/gofiber/utils v0.0.3/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY=
@ -6,10 +8,12 @@ github.com/klauspost/compress v1.10.4 h1:jFzIFaf586tquEB5EhzQG0HwGNSlgAJpG53G6Ss
github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.12.0 h1:TsB9qkSeiMXB40ELWWSRMjlsE+8IkqXHcs01y2d9aw0=
github.com/valyala/fasthttp v1.12.0/go.mod h1:229t1eWu9UXTPmoUkbpN/fctKPBY4IJoFXQnxHGXy6E=
github.com/valyala/fasthttp v1.13.1 h1:Z7kVhKP9NZz+tCSY7AVhCMPPAk7b+e5fq0l/BfdTlFc=
github.com/valyala/fasthttp v1.13.1/go.mod h1:ol1PCaL0dX20wC0htZ7sYCsvCYmrouYra0zHzaclZhE=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a h1:0R4NLDRDZX6JcmhJgXi5E4b8Wg84ihbmUKp/GvSPEzc=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

View File

@ -223,10 +223,7 @@ func (app *App) registerStatic(prefix, root string, config ...Static) *Route {
wildcard = true
prefix = strings.Split(prefix, "*")[0]
}
var stripper = len(prefix)
if isRoot {
stripper = 0
}
var stripper = len(prefix) - 1
// Fileserver settings
fs := &fasthttp.FS{
Root: root,