middleware

package
v0.0.0-...-e0cea1a Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDKey ctxKeyRequestID = 0

RequestIDKey is the key that holds the unique request ID in a request context.

Variables

This section is empty.

Functions

func AddRequestID

func AddRequestID(next http.Handler) http.Handler

AddRequestID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-0001", where "random" is a base62 random string that uniquely identifies this go process, and where the last number is an atomically incremented request counter.

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID returns a request ID from the given context if one is present. Returns the empty string if a request ID cannot be found.

func LogRequests

func LogRequests(l *zap.Logger, h http.Handler) http.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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