Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Logging = Func(func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { begin := time.Now() uri := r.RequestURI i := &interceptor{ResponseWriter: w, statusCode: http.StatusOK} next.ServeHTTP(i, r) log.Infof("%s %s (%d) %s", r.Method, uri, i.statusCode, time.Since(begin)) }) })
Logging middleware logs each HTTP request method, path, response code and duration.
Functions ¶
func MakeLabelValue ¶ added in v0.16.0
MakeLabelValue converts a Gorilla mux path to a string suitable for use in a Prometheus label value.
Types ¶
type Instrument ¶
type Instrument struct { RouteMatcher interface { Match(*http.Request, *mux.RouteMatch) bool } Duration *prometheus.SummaryVec }
Instrument is a Middleware which records timings for every HTTP request
type Interface ¶
Interface is the shared contract for all middlesware, and allows middlesware to wrap handlers.
Identity is an Interface which doesn't do anything.
func Merge ¶
Merge produces a middleware that applies multiple middlesware in turn; ie Merge(f,g,h).Wrap(handler) == f.Wrap(g.Wrap(h.Wrap(handler)))
func PathReplace ¶ added in v0.15.0
PathReplace replcase Request.RequestURI with the specified string.
Click to show internal directories.
Click to hide internal directories.