Documentation
¶
Overview ¶
Package middleware holds HTTP middleware shared by every service that runs on the common httpserver. Nothing here is domain-specific: Observer is applied by the server to all traffic, and Auth is a reusable per-route guard.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // RequestDuration stores HTTP request execution duration data to be served by the Prometheus metrics service. RequestDuration = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "http_request_duration_seconds", Help: "Duration of HTTP requests in seconds", Buckets: prometheus.DefBuckets, }, []string{"method", "path", "status_code"}, ) // RequestCount is an incremental counter measuring the total request count for each route and response status code. RequestCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "http_request_count_total", Help: "Total number of HTTP requests", }, []string{"method", "path", "status_code"}, ) )
Functions ¶
func Auth ¶
func Auth(authn auth.Authenticator) func(httprouter.Handle) httprouter.Handle
Auth returns middleware that resolves the credential in the X-Auth-Password header to a user ID via authn, injects it into the request context, and rejects the request with 401 if resolution fails. It is deliberately per-route: services wrap the handlers that need protection and leave probes and metrics open.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.