Update middleware examples

This commit is contained in:
Fenny 2020-06-25 15:54:08 +02:00
parent 3bdbc53d17
commit b95c86237d
14 changed files with 643 additions and 591 deletions

90
.github/README.md vendored
View File

@ -305,29 +305,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -449,54 +454,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

View File

@ -341,29 +341,35 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
<div dir="ltr" >
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
@ -510,58 +516,57 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
<div dir="ltr" >
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</div>
</details>
## 🧬 الرسمية Middlewares
## 🧬 Fiber Middleware
والمزيد ابلة للصيانة_ middleware _ecosystem_, لقد وضعنا رسمية [middlewares](https://docs.gofiber.io/middleware) في مستودعات منفصلة:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_de.md vendored
View File

@ -301,29 +301,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -445,54 +450,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_es.md vendored
View File

@ -301,29 +301,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -445,54 +450,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_fr.md vendored
View File

@ -301,29 +301,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -445,54 +450,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_he.md vendored
View File

@ -381,31 +381,36 @@ func main() {
### Middleware של לוגים
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
<div dir="ltr">
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
</div>
### שיתוף משאבים בין מקורות (CORS)
@ -543,29 +548,24 @@ func main() {
### Middleware של התאוששות
📖 [התאוששות](https://docs.gofiber.io/middleware#recover)
📖 [התאוששות](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
<div dir="ltr">
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
@ -576,33 +576,37 @@ func main() {
<div dir="rtl">
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
</div>
<div dir="rtl">
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
</div>
<div dir="rtl">
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
</div>

90
.github/README_id.md vendored
View File

@ -303,29 +303,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -447,54 +452,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_ja.md vendored
View File

@ -304,29 +304,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -448,54 +453,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_ko.md vendored
View File

@ -306,29 +306,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -450,54 +455,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_nl.md vendored
View File

@ -305,29 +305,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -449,54 +454,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_pt.md vendored
View File

@ -301,29 +301,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -445,54 +450,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

90
.github/README_ru.md vendored
View File

@ -303,29 +303,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -447,54 +452,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Официальные Middlewares
## 🧬 Fiber Middleware
Чтобы создать более _поддерживаемую_ middleware _экосистему_, мы вынесли [middlewares](https://docs.gofiber.io/middleware) в отдельные репозитории:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Middlewares от сторонних разработчиков

63
.github/README_tr.md vendored
View File

@ -301,7 +301,7 @@ func main() {
### Ara Katman Günlükcüsü(Logger)
📖 [Günlükcü](https://docs.gofiber.io/middleware#logger)
📖 [Günlükcü](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
@ -443,56 +443,55 @@ func main() {
}
```
### Ara Katman'dan Kurtarma
### Recover middleware
📖 [Kurtar](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Özelleştirilebilir kurtarma ayarı
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Özelleştrilebilir günlükleme
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares

View File

@ -304,29 +304,34 @@ func main() {
### Middleware logger
📖 [Logger](https://docs.gofiber.io/middleware#logger)
📖 [Logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/logger"
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app := fiber.New()
// Optional logger config
config := logger.Config{
Format: "${time} - ${method} ${path}\n",
TimeFormat: "Mon, 2 Jan 2006 15:04:05 MST",
}
// Default
app.Use(middleware.Logger())
// Logger with config
app.Use(logger.New(config))
// Custom logging format
app.Use(middleware.Logger("${method} - ${path}"))
app.Listen(3000)
// Custom Config
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Next: func(ctx *fiber.Ctx) bool {
return ctx.Path() != "/private"
},
Format: "${method} - ${path}",
Output: io.Writer,
}))
app.Listen(3000)
}
```
### Cross-Origin Resource Sharing (CORS)
@ -448,54 +453,53 @@ func main() {
### Recover middleware
📖 [Recover](https://docs.gofiber.io/middleware#recover)
📖 [Recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md)
```go
import (
"github.com/gofiber/fiber"
"github.com/gofiber/recover"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
// Optional recover config
config := recover.Config{
Handler: func(c *fiber.Ctx, err error) {
c.SendString(err.Error())
c.SendStatus(500)
},
}
app.Use(middleware.Recover())
// Logger with custom config
app.Use(recover.New(config))
app.Get("/", func(c *fiber.Ctx) {
panic("normally this would crash your app")
})
app.Listen(3000)
}
```
</details>
## 🧬 Official Middlewares
## 🧬 Fiber Middleware
For an more _maintainable_ middleware _ecosystem_, we've put official [middlewares](https://docs.gofiber.io/middleware) into separate repositories:
The Fiber middleware modules listed here are maintained by the [Fiber team](https://github.com/orgs/gofiber/people).
- [gofiber/compression](https://github.com/gofiber/compression)
- [gofiber/basicauth](https://github.com/gofiber/basicauth)
- [gofiber/requestid](https://github.com/gofiber/requestid)
- [gofiber/websocket](https://github.com/gofiber/websocket)
- [gofiber/keyauth](https://github.com/gofiber/keyauth)
- [gofiber/rewrite](https://github.com/gofiber/rewrite)
- [gofiber/recover](https://github.com/gofiber/recover)
- [gofiber/limiter](https://github.com/gofiber/limiter)
- [gofiber/session](https://github.com/gofiber/session)
- [gofiber/adaptor](https://github.com/gofiber/adaptor)
- [gofiber/logger](https://github.com/gofiber/logger)
- [gofiber/helmet](https://github.com/gofiber/helmet)
- [gofiber/embed](https://github.com/gofiber/embed)
- [gofiber/pprof](https://github.com/gofiber/pprof)
- [gofiber/cors](https://github.com/gofiber/cors)
- [gofiber/csrf](https://github.com/gofiber/csrf)
- [gofiber/jwt](https://github.com/gofiber/jwt)
| Middleware | Description | Built-in middleware |
| :--- | :--- | :--- |
| [adaptor](https://github.com/gofiber/adaptor) | Converter for net/http handlers to/from Fiber request handlers, special thanks to @arsmn! | - |
| [basicauth](https://github.com/gofiber/basicauth) | Basic auth middleware provides an HTTP basic authentication. It calls the next handler for valid credentials and 401 Unauthorized for missing or invalid credentials. | - |
| [compression](https://github.com/Fenny/fiber/blob/master/middleware/compress.md) | Compression middleware for Fiber, it supports `deflate`, `gzip` and `brotli` by default. | `middleware.Compress()` |
| [cors](https://github.com/gofiber/cors) | Enable cross-origin resource sharing \(CORS\) with various options. | - |
| [csrf](https://github.com/gofiber/csrf) | Protect from CSRF exploits. | - |
| [embed](https://github.com/gofiber/embed) | FileServer middleware for Fiber, special thanks and credits to Alireza Salary | - |
| [favicon](https://github.com/gofiber/fiber/blob/master/middleware/favicon.md) | Ignore favicon from logs or serve from memory if a file path is provided. | `middleware.Favicon()` |
| [helmet](https://github.com/gofiber/helmet) | Helps secure your apps by setting various HTTP headers. | - |
| [jwt](https://github.com/gofiber/jwt) | JWT returns a JSON Web Token \(JWT\) auth middleware. | - |
| [keyauth](https://github.com/gofiber/keyauth) | Key auth middleware provides a key based authentication. | - |
| [limiter](https://github.com/gofiber/limiter) | Rate-limiting middleware for Fiber. Use to limit repeated requests to public APIs and/or endpoints such as password reset. | - |
| [logger](https://github.com/gofiber/fiber/blob/master/middleware/logger.md) | HTTP request/response logger. | `middleware.Logger()` |
| [pprof](https://github.com/gofiber/pprof) | Special thanks to Matthew Lee \(@mthli\) | - |
| [recover](https://github.com/gofiber/fiber/blob/master/middleware/recover.md) | Recover middleware recovers from panics anywhere in the stack chain and handles the control to the centralized[ ErrorHandler](error-handling.md). | `middleware.Recover()` |
| [rewrite](https://github.com/gofiber/rewrite) | Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links. | - |
| [requestid](https://github.com/Fenny/fiber/blob/master/middleware/request_id.md) | Request ID middleware generates a unique id for a request. | `middleware.RequestID()` |
| [session](https://github.com/gofiber/session) | This session middleware is build on top of fasthttp/session by @savsgio MIT. Special thanks to @thomasvvugt for helping with this middleware. | - |
| [template](https://github.com/gofiber/template) | This package contains 8 template engines that can be used with Fiber `v1.10.x` Go version 1.13 or higher is required. | - |
| [websocket](https://github.com/gofiber/websocket) | Based on Fasthttp WebSocket for Fiber with Locals support! | - |
## 🌱 Third Party Middlewares