requestid

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTransport

func ApplyTransport(client *http.Client)

ApplyTransport injects the request-id transport to an http client

func FromContext

func FromContext(ctx context.Context) string

FromContext returns the request id stored in the the context

func FromRequest

func FromRequest(r *http.Request) string

func Middleware

func Middleware(inner http.Handler) http.Handler

Middleware wraps an http handler. Before the inner handler is called, the X-Request-ID header is extracted and injected into the request context. It is safe to be called if the header does not exists

func NewID

func NewID() string

func RequestIDLogger

func RequestIDLogger(logger logrus.FieldLogger, requestID string) logrus.FieldLogger

func ToContext

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

func Transport

func Transport(inner http.RoundTripper) http.RoundTripper

Transport wraps an inner transport. It adds the request-id from the request context to the request header.

Types

type Config

type Config struct {
	RequestID string `envconfig:"X-REQUEST-ID" default:""`
}

Allow getting requestID from environment variable. To be used in tools, not in services

Jump to

Keyboard shortcuts

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