requestid

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package requestid provides HTTP request ID functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) (string, bool)

FromContext returns the request ID from the context if it exists and is not the empty value.

func NewContext

func NewContext(ctx context.Context, requestID string) context.Context

NewContext returns a new context with the given request ID added to the context.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func New

func New(legacyTraceHeader string) *Handler

New creates a new request ID [handler]. It takes a trace header, which is used keep the legacy behavior intact, which relies on the X-Smallstep-Id header instead of X-Request-Id.

func (*Handler) Middleware

func (h *Handler) Middleware(next http.Handler) http.Handler

Middleware wraps an http.Handler with request ID extraction from the X-Reqeust-Id header by default, or from the X-Smallstep-Id header if not set. If both are not set, a new request ID is generated. In all cases, the request ID is added to the request context, and set to be reflected in the response.

Jump to

Keyboard shortcuts

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