handlers

package
v0.0.0-...-19a0cb6 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProxyHandler

func ProxyHandler(env *Env, w http.ResponseWriter, r *http.Request) error

ProxyHandler sends http requests to upstream.

func Status

func Status(env *Env, w http.ResponseWriter, r *http.Request) error

Status is an http hangler used as a health/readiness check in k8s and openshift.

Types

type Env

type Env struct {
	Proxy *httputil.ReverseProxy
	Log   *logrus.Logger
}

Env represents options always present in handlers.

type Error

type Error interface {
	error
	Status() int
}

Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.

type Handler

type Handler struct {
	*Env
	H func(e *Env, w http.ResponseWriter, r *http.Request) error
}

Handler is a wrapper to satisfy http.Handler and to pass around an *Env context.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows our Handler type to satisfy http.Handler.

type StatusError

type StatusError struct {
	Code int
	Err  error
}

StatusError represents an error with an associated HTTP status code.

func (StatusError) Error

func (se StatusError) Error() string

Allows StatusError to satisfy the error interface.

func (StatusError) Status

func (se StatusError) Status() int

Status returns our HTTP status code.

Jump to

Keyboard shortcuts

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