handler

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 7 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 `json:"handler" validate:"required"`

	// Method to run the `Handler`.
	Method string `json:"method" validate:"required"`

	// Path to run the `Handler`.
	Path string `json:"path" validate:"required"`
}

Handler definition.

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 Metrics added in v0.0.8

func Metrics() Handler

Metrics serves metrics.

func New

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

New is `Handler` factory.

func OK

func OK() Handler

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

func Readiness

func Readiness(readinessStates ...*ReadinessDeterminer) 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. Multiple readinesses determiners can be passed. In this case, only if ALL are ready, the server will be considered ready.

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 ReadinessDeterminer added in v0.0.4

type ReadinessDeterminer struct {
	// contains filtered or unexported fields
}

ReadinessDeterminer definition. It determines if `name` is ready.

func NewReadinessDeterminer added in v0.0.4

func NewReadinessDeterminer(name string) *ReadinessDeterminer

NewReadinessDeterminer is the Readiness factory.

func (*ReadinessDeterminer) GetName added in v0.0.4

func (t *ReadinessDeterminer) GetName() string

Get state name.

func (*ReadinessDeterminer) GetReadiness added in v0.0.4

func (t *ReadinessDeterminer) GetReadiness() bool

Get readiness state.

func (*ReadinessDeterminer) SetName added in v0.0.4

func (t *ReadinessDeterminer) SetName(name string)

Set state name.

func (*ReadinessDeterminer) SetReadiness added in v0.0.4

func (t *ReadinessDeterminer) SetReadiness(v bool)

Set readiness state.

Jump to

Keyboard shortcuts

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