middleware

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TraceIDKey is the key for trace ID in context
	TraceIDKey contextKey = "trace_id"
	// TraceIDHeader is the HTTP header name for trace ID
	TraceIDHeader = "X-Trace-ID"
)
View Source
const (
	// StartTimeKey is the key for request start time in context
	StartTimeKey timingContextKey = "start_time"
)

Variables

This section is empty.

Functions

func GetRequestDuration

func GetRequestDuration(ctx context.Context) int64

GetRequestDuration calculates the duration since request start time Returns duration in milliseconds

func GetRequestDurationFromRequest

func GetRequestDurationFromRequest(r *http.Request) int64

GetRequestDurationFromRequest calculates the duration from request context

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID retrieves the trace ID from context

func GetTraceIDFromRequest

func GetTraceIDFromRequest(r *http.Request) string

GetTraceIDFromRequest retrieves the trace ID from request context

func TimingMiddleware

func TimingMiddleware() func(next http.Handler) http.Handler

TimingMiddleware records request start time for calculating processing duration

func TraceIDMiddleware

func TraceIDMiddleware() func(next http.Handler) http.Handler

TraceIDMiddleware adds a trace ID to each request If the request already has a trace ID in the header, it will be used Otherwise, a new UUID will be generated

Types

This section is empty.

Jump to

Keyboard shortcuts

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