1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-22 15:03:57 +00:00
M. Efe Çetin b74676704d
Add disable html support to monitor middleware. (#1620)
* Add disable html support to monitor middleware.

* Change field.

* Update README.md

* Update middleware/monitor/config.go

* Fix tests.

Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>
2021-12-05 19:28:50 +01:00
..
2021-01-21 18:29:29 -03:00

Monitor

Monitor middleware for Fiber that reports server metrics, inspired by express-status-monitor

⚠️ Warning: Monitor is still in beta, API might change in the future!

Signatures

func New() fiber.Handler

Examples

Import the middleware package and assign it to a route.

package main

import (
	"log"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/monitor"
)

func main() {
	app := fiber.New()
	
	app.Get("/dashboard", monitor.New())
	
	log.Fatal(app.Listen(":3000"))
}

Config

// Config defines the config for middleware.
type Config struct {
	// To disable serving HTML, you can make true this option.
	//
	// Optional. Default: false
	APIOnly bool
	
	// Next defines a function to skip this middleware when returned true.
	//
	// Optional. Default: nil
	Next func(c *fiber.Ctx) bool
}

Default Config

var ConfigDefault = Config{
	APIOnly: false,
	Next: nil,
}