middleware

package
v0.5.9-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APILoggerKey = &contextKey{"logger"}

APILoggerKey is a context key used for associating a logger with a request.

View Source
var StartTimeKey = &contextKey{"startTime"}

StartTimeKey is a context key used for storing the start time of a request.

Functions

func APILogger

func APILogger(next http.Handler) http.Handler

APILogger is a middleware that injects a logger, configured with a request ID, into the request context for use throughout the request's lifecycle.

func DefaultLogger

func DefaultLogger(next http.Handler) http.Handler

DefaultLogger is a middleware that provides basic request logging using chi's built-in Logger middleware.

func GetStartTime

func GetStartTime(ctx context.Context) time.Time

GetStartTime returns the start time from the given context if one is present. If the start time is not present or the context is nil, returns the zero time.

func ReadOnlyMode

func ReadOnlyMode(next http.Handler) http.Handler

ReadOnlyMode disallows non-GET requests in read-only mode.

func Timing

func Timing(next http.Handler) http.Handler

Timing is a middleware that captures the current time at the start of a request and stores it in the request context. This start time can be used to measure request processing duration.

Types

This section is empty.

Jump to

Keyboard shortcuts

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