middleware

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package middleware provides some useful and commonly implemented middleware functions for StormRPC servers.

Package middleware provides some useful and commonly implemented middleware functions for StormRPC servers.

Package middleware provides some useful and commonly implemented middleware functions for StormRPC servers.

Package middleware provides some useful and commonly implemented middleware functions for StormRPC servers.

Package middleware provides some useful and commonly implemented middleware functions for StormRPC servers.

Index

Constants

View Source
const RequestIDHeader = "X-Request-Id"

RequestIDHeader represents the key in the header map that stores the unique request id.

Variables

This section is empty.

Functions

func Logger

func Logger(l *slog.Logger) func(next stormrpc.HandlerFunc) stormrpc.HandlerFunc

Logger logs request scoped information such as request id, trace information, and request duration. This middleware should be applied after RequestID, and Tracing.

func NewContextWithRequestID

func NewContextWithRequestID(ctx context.Context, id string) context.Context

NewContextWithRequestID will take the original context and use it as the parent context for the returned context. The passed in id will be added to this new context.

func Recoverer

func Recoverer(next stormrpc.HandlerFunc) stormrpc.HandlerFunc

Recoverer handles recovering from a panic in other HandlerFunc's.

func RequestID

func RequestID(next stormrpc.HandlerFunc) stormrpc.HandlerFunc

RequestID extracts the value from the request header if its present. If none is present a uuid is generated to serve as the request id. This id is passed into the request context to be extracted later. It is also added to the response headers.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext extracts the request id from the context if one is present. If no request id is present an empty string will be returned.

func Tracing

func Tracing(tracer trace.Tracer) func(next stormrpc.HandlerFunc) stormrpc.HandlerFunc

Tracing extracts the span from the incoming request headers. If none is present a new root span is created. This tracing information is also passed into the response headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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