middleware

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const CtxRequestIDKey = ctxRequestID("request_id")
View Source
const CtxRouteNameKey = ctxRouteName("route_name")

Variables

This section is empty.

Functions

func RequestID

func RequestID(h http.Handler) http.Handler

RequestID is a server level middleware which creates a unique request identifier and links it to its corresponding key in the request context. If the `X-Request-ID` header already presents, its value is used instead. The purpose of this middleware is to inject the value to the logs.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext returns the current request identifier from the request context.

func RouteName

func RouteName(val string) func(http.Handler) http.Handler

RouteName is a route level middleware which names the given route and links it to its corresponding key in the request context. The purpose of this middleware is to inject the value to the logs.

func RouteNameFromContext

func RouteNameFromContext(ctx context.Context) string

RouteNameFromContext returns the name of the current route from 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