handler

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

package handler provides a collection of useful/built-in handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// Handler function.
	Handler http.HandlerFunc

	// Method to run the `Handler`.
	Method string

	// Path to run the `Handler`.
	Path string
}

Handler definition.

func ExpVar

func ExpVar() Handler

ExpVar serves metrics.

func Liveness

func Liveness() Handler

Liveness indicates the server is up, and running. It follows the "standard" which is send `200` status code, and "OK" in the body.

func New

func New(method string, path string, handler http.HandlerFunc) Handler

New is `Handler` factory.

func OK

func OK() Handler

OK replies with `200` status code, and "OK" in the body.

func Readiness

func Readiness(readinessFunc ReadinessFunc) Handler

Readiness indicates the server is up, running, and ready to work. It follows the "standard" which is send `200` status code, and "OK" in the body if it's ready, otherwise sends `503`, "Service Unavailable", and the error.

func Stop

func Stop() Handler

Stop allows the server to be remotely, and gracefully stopped. Optionally set the `hard` query param to `true` to immediately kill the server.

type ReadinessFunc

type ReadinessFunc func() error

ReadinessFunc determines readiness. If error isn't `nil`, it means server isn't ready.

NOTE: Be mindful that a readiness probe performs this every N-{s|ms}.

Jump to

Keyboard shortcuts

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