package
0.0.0-20230307133214-552cc5bb9650
Repository: https://github.com/phogolabs/rest.git
Documentation: pkg.go.dev
# Functions
GetLogger returns the associated request logger.
InstrumentHandlerCounter is a middleware that wraps the provided http.Handler to observe the request result with the provided CounterVec.
InstrumentHandlerDuration is a middleware that wraps the provided http.Handler to observe the request duration with the provided ObserverVec.
InstrumentLabels returns the instrument labels.
LiveReloader reloads a webpage.
Logger is a middleware that logs the start and end of each request, along with some useful data about what was requested, what the response status was, and how long it took to return.
LoggerFields returns the logger's fields.
LoggerOptionWithFields creates a new logger option with fields.
LoggerWithOption returns a logger middleware.
Metrics enables metrics for each request.
NewReloader creates a new reloader.
Recoverer is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a HTTP 500 (Internal Server Error) status if possible.
# Variables
GetReqID returns a request ID from the given context if one is present.
Heartbeat endpoint middleware useful to setting up a path like `/ping` that load balancers or uptime testing external services can make a request before hitting any routes.
NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent a router (or subrouter) from being cached by an upstream proxy and/or client.
RealIP is a middleware that sets a http.Request's RemoteAddr to the results of parsing either the X-Forwarded-For header or the X-Real-IP header (in that order).
RequestID is a middleware that injects a request ID into the context of each request.
SetContentType is a middleware that forces response Content-Type.
Status sets a HTTP response status code hint into request context at any point during the request life-cycle.
StripSlashes is a middleware that will match request paths with a trailing slash, strip it from the path and continue routing through the mux, if a route matches, then it will serve the handler.
# Interfaces
LoggerOption represent a logger option.
# Type aliases
LoggerOptionFunc represents a function.