middleware

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIdCtxKey = "requestId"
	RequestIdHeader = "X-Request-Id"
)

Variables

This section is empty.

Functions

func GetRequestId

func GetRequestId(ctx context.Context) string

GetRequestId returns the ID for a given request if a request ID is present. Returns an empty string if no request ID is found.

func RequestId

func RequestId(h http.Handler) http.Handler

RequestId is a middleware that creates an Id for the intercepted request. The Id is of the form "%s-%07d", where %s is a random hex string of length 14 and %07d is a sequential number.

func RequestLogger

func RequestLogger(h http.Handler, logger *slog.Logger) http.Handler

RequestLogger is a middleware that logs request information. The information that it logs are: - Protocol Version - Request Id - Duration - Status

Types

This section is empty.

Jump to

Keyboard shortcuts

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