route

package
v1.1.26-test Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderRequestID = "X-Request-Id"

HeaderRequestID carries the caller's trace id; it is echoed back as the request's trace id.

Variables

This section is empty.

Functions

func InjectCommonContextVars

func InjectCommonContextVars(ctx context.Context) context.Context

InjectCommonContextVars ensures ctx carries a non-empty trace id and a remote IP value (empty when unknown), so downstream logging can rely on both keys being present.

func InjectCommonRequestContextVars

func InjectCommonRequestContextVars(r *http.Request) *http.Request

InjectCommonRequestContextVars returns the request with a context carrying the trace id from the X-Request-Id header (a fresh UUID when absent) and the caller's remote IP.

func Route

func Route(rtr *mux.Router, path string, routerHandler http.HandlerFunc) *mux.Route

Route registers routerHandler at path, wrapping it so that every request gets a trace id and remote IP in its context and its duration observed in http_request_duration_seconds{method,path}.

Types

This section is empty.

Jump to

Keyboard shortcuts

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