healthcheck

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 2 Imported by: 1

README

Fiber-health-check 🩺 Middleware

codecov License GoDoc Go Report Card

🩺Fiber-health-check middleware support health-check for Fiber⚡️ framework.

Signatures

func New(config ...Config) fiber.Handler

How to use

Frist import the midllware from Github,

go get -u github.com/gofiber/v2
go get -u github.com/aschenmaker/fiber-health-check

Then create a Fiber app with app := fiber.New().

Default Config

app.Use(healthcheck.New())

Custom Config

app.Use(healthcheck.New(
	HeaderName:   "X-Custom-Header",
	HeaderValue:  "customValue",
	ResponseCode: http.StatusTeapot,
	ResponseText: "teapot",
))

Config

// Config defines the config for middleware
type Config struct {
    // HeaderName defines the health check header key
    //
    // Optional. Default: "X-Health-Check"
    HeaderName   string
    // HeaderValue defines the health check header val
    //
    // Optional. Default: "1"
    HeaderValue  string
    // ResponseCode defines the health check response code
    //
    // Optional. Default: http.StatusOK
    ResponseCode int
    // ResponseText defines the health check response description
    //
    // Optional. Default: "ok"
    ResponseText string
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultHeaderName default header name
	DefaultHeaderName = "X-Health-Check"

	// DefaultHeaderValue default header value
	DefaultHeaderValue = "1"

	// DefaultResponseCode default response code
	DefaultResponseCode = http.StatusOK

	// DefaultResponseText default response text
	DefaultResponseText = "ok"

	// DefaultConfig default config
	DefaultConfig = Config{
		HeaderName:   DefaultHeaderName,
		HeaderValue:  DefaultHeaderValue,
		ResponseCode: DefaultResponseCode,
		ResponseText: DefaultResponseText,
	}
)

Functions

func New

func New(config ...Config) fiber.Handler

New creates a new middleware handler

Types

type Config

type Config struct {
	HeaderName   string
	HeaderValue  string
	ResponseCode int
	ResponseText string
}

Config defines the config for middleware.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL