middleware

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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