mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-08 08:39:41 +00:00
* 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>
43 lines
775 B
Go
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
|
|
}
|