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

43 lines
775 B
Go

package monitor
import "github.com/gofiber/fiber/v2"
// Config defines the config for middleware.
type Config struct {
// Whether the service should expose only the monitoring API.
//
// 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
}
var ConfigDefault = Config{
APIOnly: false,
Next: nil,
}
func configDefault(config ...Config) Config {
// Return default config if nothing provided
if len(config) < 1 {
return ConfigDefault
}
// Override default config
cfg := config[0]
// Set default values
if cfg.Next == nil {
cfg.Next = ConfigDefault.Next
}
if !cfg.APIOnly {
cfg.APIOnly = ConfigDefault.APIOnly
}
return cfg
}