Documentation
¶
Index ¶
- func AssertStatusCode(r *http.Response, statusCode int) error
- func InstrumentHandler(handler http.Handler) http.Handler
- func ResolveRequestURL(r *http.Request) (*url.URL, error)
- func SpanFromRequest(r *http.Request) (context.Context, trace.Span)
- type AuthHandler
- type AuthHandlerFunc
- type AuthMux
- type BasicAuthHandler
- type BearerToken
- type Client
- type Error
- type Link
- type StatusRecorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertStatusCode ¶ added in v0.16.0
AssertStatusCode returns an error if the response does not match the given status code.
func InstrumentHandler ¶ added in v0.13.0
InstrumentHandler instruments a http.Handler. Instrumented handlers are required to set the http.route attribute to the span if available.
If CORS is in use, it's the wrapped handler's responsibility to allow the traceresponse header.
SEE: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-server-semantic-conventions
func SpanFromRequest ¶ added in v0.13.0
SpanFromRequest returns the current span for a handler instrumented using InstrumentHandler. Panics if handler is not instrumented. A span received this way MUST NOT be manually closed. It is closed once the instrumented handler completed the request.
Types ¶
type AuthHandler ¶ added in v0.16.0
type AuthHandlerFunc ¶ added in v0.16.0
func (AuthHandlerFunc) HandleAuth ¶ added in v0.16.0
func (f AuthHandlerFunc) HandleAuth(r *http.Request) error
type AuthMux ¶ added in v0.16.0
type AuthMux struct {
// contains filtered or unexported fields
}
func NewAuthMux ¶ added in v0.16.0
func NewAuthMux() *AuthMux
func (*AuthMux) Handle ¶ added in v0.16.0
func (a *AuthMux) Handle(pattern string, handler AuthHandler)
func (*AuthMux) HandleFunc ¶ added in v0.16.0
type BasicAuthHandler ¶ added in v0.16.0
func (BasicAuthHandler) HandleAuth ¶ added in v0.16.0
func (h BasicAuthHandler) HandleAuth(r *http.Request) error
type BearerToken ¶ added in v0.16.0
type BearerToken string
func (BearerToken) HandleAuth ¶ added in v0.16.0
func (t BearerToken) HandleAuth(r *http.Request) error
type Client ¶
func (*Client) Collect ¶
func (c *Client) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*Client) Describe ¶
func (c *Client) Describe(descs chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
func (*Client) Do ¶
See http.Client.Do.
func (*Client) DoCached ¶
DoCached returns a cached response for the request. If no cache entry exists, http.Client.Do is used. If the request succeeds, its response is cached if the response code is 2xx. It is the caller's responsibility to ensure that caching the request is sensible (i.e. only for GET requests). NOTE: Cached responses for URLs that were redirected will not have the correct request URL for the response - it will be the original request rather than the request to the final resource.
type Link ¶
func ParseLinkHeader ¶
ParseLinkHeader parses a Link header.
SEE: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link.
type StatusRecorder ¶ added in v0.13.0
type StatusRecorder struct { Writer http.ResponseWriter // contains filtered or unexported fields }
func (*StatusRecorder) Flush ¶ added in v0.15.0
func (s *StatusRecorder) Flush()
Flush implements http.Flusher.
func (*StatusRecorder) Header ¶ added in v0.13.0
func (s *StatusRecorder) Header() http.Header
Header implements http.ResponseWriter.
func (*StatusRecorder) StatusCode ¶ added in v0.13.0
func (s *StatusRecorder) StatusCode() int
func (*StatusRecorder) Write ¶ added in v0.13.0
func (s *StatusRecorder) Write(b []byte) (int, error)
Write implements http.ResponseWriter.
func (*StatusRecorder) WriteHeader ¶ added in v0.13.0
func (s *StatusRecorder) WriteHeader(statusCode int)
WriteHeader implements http.ResponseWriter.