1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-23 12:03:49 +00:00

52 lines
968 B
Markdown
Raw Normal View History

2020-09-29 01:28:43 +02:00
# Monitor
2020-09-29 02:38:24 +02:00
Monitor middleware for [Fiber](https://github.com/gofiber/fiber) that reports server metrics, inspired by [express-status-monitor](https://github.com/RafalWilinski/express-status-monitor)
2020-09-29 01:28:43 +02:00
:warning: **Warning:** Monitor is still in beta, API might change in the future!
![](https://i.imgur.com/nHAtBpJ.gif)
2020-09-29 01:28:43 +02:00
### Signatures
```go
func New() fiber.Handler
```
### Examples
2020-09-29 02:36:15 +02:00
Import the middleware package and assign it to a route.
2020-09-29 01:28:43 +02:00
```go
2020-09-29 02:35:41 +02:00
package main
2020-09-29 01:28:43 +02:00
import (
2020-09-29 02:35:41 +02:00
"log"
2020-09-29 01:28:43 +02:00
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/monitor"
)
2020-09-29 02:35:41 +02:00
func main() {
app := fiber.New()
2020-09-29 02:36:15 +02:00
2020-09-29 02:35:41 +02:00
app.Get("/dashboard", monitor.New())
2020-09-29 02:36:15 +02:00
2020-09-29 02:35:41 +02:00
log.Fatal(app.Listen(":3000"))
}
```
## Config
```go
// Config defines the config for middleware.
type Config struct {
// Next defines a function to skip this middleware when returned true.
//
// Optional. Default: nil
Next func(c *fiber.Ctx) bool
}
```
## Default Config
```go
var ConfigDefault = Config{
Next: nil,
}
```