reqid

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContextToLogger

func FromContextToLogger(ctx context.Context, log logrus.FieldLogger) *logrus.Entry

FromContextToLogger extracts request id from context and returns logger with added field

func ToContext

func ToContext(ctx context.Context, reqID RequestID) context.Context

ToContext returns a context based on passed one with injected request id

Types

type RequestID

type RequestID string

RequestID is a random hex string. It doesn't correspond to UUID RFC 4122 format because it would be an overkill for such small project. Also it can be easily modified to match RFC 4122

func FromContext

func FromContext(ctx context.Context) RequestID

FromContext extracts request id from context. If request id doesn't exist, it generates a new one

func New

func New() RequestID

New creates a new request id

func (RequestID) ToString

func (r RequestID) ToString() string

Jump to

Keyboard shortcuts

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