middleware/healthcheck
import "github.com/gofiber/fiber/v3/middleware/healthcheck"
Constants
Source: middleware/healthcheck/config.go:48
const (
// LivenessEndpoint is the conventional path for a liveness check.
// Register the middleware on this path to expose it.
LivenessEndpoint = "/livez"
// ReadinessEndpoint is the conventional path for a readiness check.
// Register the middleware on this path to expose it.
ReadinessEndpoint = "/readyz"
// StartupEndpoint is the conventional path for a startup check.
// Register the middleware on this path to expose it.
StartupEndpoint = "/startupz"
)Source: middleware/healthcheck/config.go:12
const (
// FormatText returns a plain text response (default behavior).
FormatText ResponseFormat = iota
// FormatJSON returns a JSON response.
FormatJSON
// FormatXML returns an XML response.
FormatXML
// FormatMsgPack returns a MessagePack response.
FormatMsgPack
// FormatCBOR returns a CBOR response.
FormatCBOR
)Variables
ConfigDefault is the default configuration.
Source: middleware/healthcheck/config.go:62
var ConfigDefault = Config{
Next: nil,
Probe: defaultProbe,
}Functions
func New(config ...Config) fiber.Handler
Source: middleware/healthcheck/healthcheck.go:14
New returns a health-check handler that responds based on the provided configuration.
Types
type Config
Source: middleware/healthcheck/config.go:24
Config defines the configuration options for the healthcheck middleware.
type Config struct {
// Next defines a function to skip this middleware when returned true. If this function returns true
// and no other handlers are defined for the route, Fiber will return a status 404 Not Found, since
// no other handlers were defined to return a different status.
//
// Optional. Default: nil
Next func(fiber.Ctx) bool
// Probe is executed to determine the current health state. It can be used for liveness,
// readiness or startup checks. Returning true indicates the application is healthy.
//
// Optional. Default: func(c fiber.Ctx) bool { return true }
Probe func(fiber.Ctx) bool
// ResponseFormat specifies the format of the healthcheck response.
// Supported formats: Text (default), JSON, XML, MsgPack, CBOR.
//
// Optional. Default: FormatText
ResponseFormat ResponseFormat
}Fields
Next func(fiber.Ctx) boolNext defines a function to skip this middleware when returned true. If this function returns true and no other handlers are defined for the route, Fiber will return a status 404 Not Found, since no other handlers were defined to return a different status.
Optional. Default: nil
Probe func(fiber.Ctx) boolProbe is executed to determine the current health state. It can be used for liveness, readiness or startup checks. Returning true indicates the application is healthy.
Optional. Default: func(c fiber.Ctx) bool { return true }
ResponseFormat ResponseFormatResponseFormat specifies the format of the healthcheck response. Supported formats: Text (default), JSON, XML, MsgPack, CBOR.
Optional. Default: FormatText
type ResponseFormat
Source: middleware/healthcheck/config.go:8
ResponseFormat defines the format of the healthcheck response.
type ResponseFormat int