middleware

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(logger *slog.Logger) gin.HandlerFunc

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *slog.Logger

Retrieves the logger from the context. It creates a new one if it can't be found.

func LoggerToContext

func LoggerToContext(ctx context.Context, logger *slog.Logger) context.Context

Stores the logger in the context.

func TraceToHTTPHeaders

func TraceToHTTPHeaders(trace Trace, header http.Header)

ToHTTPHeaders adds tracing information to HTTP headers.

Types

type Trace

type Trace struct {
	TraceID      string
	ParentSpanID string
	SpanID       string
}

func NewTrace

func NewTrace() Trace

NewTrace creates a new trace with a new `TraceID`.

func TraceFromHTTPHeaders

func TraceFromHTTPHeaders(headers http.Header) Trace

FromHTTPHeaders extracts tracing information from HTTP headers. If no tracing information is found, a new trace is created with only `TraceID` set.

func (Trace) NewSpan

func (t Trace) NewSpan() Trace

NewSpan create a new trace with the same `TraceID`, `ParentSpanID` set as the current `SpanID` and a new `SpanID`.

Jump to

Keyboard shortcuts

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