middleware

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestIDHeader = "X-Request-Id"
View Source
var ValidRequestIdRegex = regexp.MustCompile("^[0-9a-f]{8}$")

Functions

func CheckRequestAuthorization

func CheckRequestAuthorization(conf *config.SecurityConfig) func(http.Handler) http.Handler

func CorsHeadersMiddleware

func CorsHeadersMiddleware(config *config.SecurityConfig) func(http.Handler) http.Handler

func RequestIdMiddleware

func RequestIdMiddleware(next http.Handler) http.Handler

RequestIdMiddleware creates a HandlerFunc that obtains the request id from the request header, or failing that, creates a new request id, and places it in the request context. It also adds it to the response under the same header. This automatically also leads to all logging using this context to log the request id.

func RequestLoggerMiddleware

func RequestLoggerMiddleware(next http.Handler) http.Handler

RequestLoggerMiddleware creates a HandlerFunc that logs each incoming request with a single line. Place it below RequestIdMiddleware and the log line will include the request id.

Types

This section is empty.

Jump to

Keyboard shortcuts

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