requestid

package
v0.0.0-...-d75332b Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRequestIDFromContext

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

GetRequestIDFromContext extracts the request ID from the provided context.

Parameters: - ctx: The context from which to extract the request ID.

Returns: - string: The extracted request ID. - bool: A boolean value indicating whether the request ID was successfully extracted.

func GetRequestIDFromRequest

func GetRequestIDFromRequest(r *http.Request) (string, bool)

GetRequestIDFromRequest extracts the request ID from the provided HTTP request's context.

Parameters: - r: A pointer to the HTTP request from which to extract the request ID.

Returns: - string: The extracted request ID. - bool: A boolean value indicating whether the request ID was successfully extracted.

func New

func New(genFn IDGenerator) func(http.Handler) http.Handler

New is a higher-order function that takes an IDGenerator function as an argument and returns a function that takes an http.Handler as an argument and returns an http.Handler.

Parameters: - genFn: A function that generates a unique ID.

Returns: - func(http.Handler) http.Handler: A function that wraps the provided http.Handler with request ID generation and setting.

func RequestID

func RequestID(next http.Handler) http.Handler

RequestID is a middleware function that wraps the provided http.Handler with request ID generation and setting. It also adds a "X-Request-Id" header to the response.

Parameters: - next: The http.Handler to be wrapped with request ID generation and setting.

Returns: - http.Handler: The wrapped http.Handler.

func ULIDGenerator

func ULIDGenerator() string

ULIDGenerator is a function that generates a new ULID as a string.

func UUIDGenerator

func UUIDGenerator() string

UUIDGenerator is a function that generates a new UUID as a string.

Types

type IDGenerator

type IDGenerator func() string

IDGenerator is a type definition for a function that generates a unique ID as a string.

Jump to

Keyboard shortcuts

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