requestid

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: LGPL-2.1 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const RequestIDKey requestIDKey = "custom.requestID"

RequestIDKey define a constant string for the request ID key

Variables

View Source
var DefaultRequestIDConfig = Config{
	Generator:    generator,
	TargetHeader: echo.HeaderXRequestID,
}

DefaultRequestIDConfig is the default RequestID middleware config.

Functions

func GetContextRequestID

func GetContextRequestID(ctx context.Context) string

GetContextRequestID takes a context as input and returns a pointer to a string of strings

func New

func New() echo.MiddlewareFunc

New returns a X-Request-ID middleware.

func NewWithConfig

func NewWithConfig(config Config) echo.MiddlewareFunc

NewWithConfig returns a X-Request-ID middleware with config.

func WithContextRequestID

func WithContextRequestID(ctx context.Context, rid string) context.Context

WithContextRequestID takes a context and request id as inputs and returns a new context with a value

Types

type Config

type Config struct {
	// Generator defines a function to generate an ID.
	// Optional. Defaults to generator for random string of length 32.
	Generator func() string

	// RequestIDHandler defines a function which is executed for a request id.
	RequestIDHandler func(echo.Context, string)

	// TargetHeader defines what header to look for to populate the id
	TargetHeader string
}

Config defines the config for RequestID middleware.

Jump to

Keyboard shortcuts

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