healthzhttp

package module
v0.0.0-...-ebe0ad0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

healthzhttp

GoDoc Go Report Card

Implements a healthz check that will make an HTTP request.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckHTTP

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

CheckHTTP is an HTTP healthz check

Example
checker := healthz.NewChecker()
chk, err := NewCheck("http://example.com/path")
if err != nil {
	log.Fatal(err)
}
checker.AddCheck("remote_service", chk)
http.ListenAndServe(":8080", checker)
Output:

func NewCheck

func NewCheck(endpoint string, opts ...Option) (*CheckHTTP, error)

NewCheck creates a new CheckHTTP.

func (CheckHTTP) Check

func (c CheckHTTP) Check(ctx context.Context) *healthz.Response

Check performs the check

type Option

type Option func(*options) error

Option is used to customize the summarizer

func WithAllowedStatusCode

func WithAllowedStatusCode(status int) Option

WithAllowedStatusCode adds a status code that won't trigger an error

func WithBasicAuth

func WithBasicAuth(username, password string) Option

WithBasicAuth sets basic auth credentials to be used for each request

func WithBody

func WithBody(body []byte) Option

WithBody sets the body to be sent along with each request

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets the HTTP client to use for the checks

func WithMethod

func WithMethod(method string) Option

WithMethod sets the HTTP method to use for the checks

func WithRegexp

func WithRegexp(expr string) Option

WithRegexp performs a content check on the body of the HTTP response.

func WithoutAllowedStatusCode

func WithoutAllowedStatusCode(status int) Option

WithoutAllowedStatusCode removes a status code from the list of allowed codes. This is useful to remove the default 200 status code

Jump to

Keyboard shortcuts

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