handler

package
v0.0.0-...-a4359f9 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogFields

func LogFields(r *http.Request, keysAndValues ...interface{}) []interface{}

LogFields logs the given keys and values for a request

func Logger

func Logger(log *logger.Logger, h http.Handler) http.Handler

Logger is a handler that logs requests using Zap

func Metrics

func Metrics(h http.Handler, routeMatcher RouteMatcher) http.Handler

Metrics is a handler that collects performance metrics

func Recovery

func Recovery(log *logger.Logger, next http.Handler) http.Handler

Recovery is a handler for handling panics

func Tracer

func Tracer(tracer *tracing.Tracer, h http.Handler, routeMatcher RouteMatcher) http.Handler

Tracer is a handler that adds tracing for handlers

func VarzHandler

func VarzHandler(w http.ResponseWriter, r *http.Request)

Types

type Error

type Error struct {
	Message string
	Code    int
}

Error is the message and http status code to return

func BadRequest

func BadRequest(message string) *Error

BadRequest is a convenience function for returning a bad request error

func InternalServerError

func InternalServerError() *Error

InternalServerError is a convenience function for returning an internal server error

type Handler

type Handler func(w http.ResponseWriter, r *http.Request) *Error

Handler wraps a http handler and deals with responding to errors

func Health

func Health(healthChecker *health.Checker) Handler

Health is a handler for health check status

func (Handler) ServeHTTP

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

type MuxRouteMatcher

type MuxRouteMatcher struct {
	Router *mux.Router
}

MuxRouteMatcher maxes routes for a mux router

func (*MuxRouteMatcher) Match

func (m *MuxRouteMatcher) Match(r *http.Request) string

Match returns the mux route name of a given request, falling back to the path template if not set

type RouteMatcher

type RouteMatcher interface {
	Match(r *http.Request) string
}

RouteMatcher matches routes

Jump to

Keyboard shortcuts

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