uamid

package
v0.0.0-...-3b91d86 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRequestID

func GetRequestID(r *http.Request) string

GetRequestID gets the request id from a request's context. If none was set (i.e. the RequestID middleware wasn't run), then an empty string is returned.

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer recovers from panics, and reports an internal server error. The panic will be logged, along with a stack trace.

func RequestID

func RequestID(fieldKey string) func(http.Handler) http.Handler

RequestID manages request IDs, similarly to Heroku's method. If the client sets X-Request-ID, then it is used. If no request ID is provided, or the provided request ID is not between 20 and 200 characters (inclusive), then a ULID is generated and used.

The request ID is also written to the ResponseWriter, and if a zap logger is in the request context, added with the provided field key.

NOTE: The http.Handler interface requires that handlers not modify the request. In order to get the "real" request ID, use the GetRequestID function.

func RequestLogger

func RequestLogger(next http.Handler) http.Handler

RequestLogger logs information about HTTP requests using the zap logger in the request context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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