interceptors

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDHeader string = "X-Request-Id"
)

Variables

View Source
var ErrInternalError = errors.New("internal server error")

Functions

func ContextualLoggerUnary

func ContextualLoggerUnary(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

ContextualLoggerUnary Enriches the context with tenant and request metadata for structured logging.

This interceptor extracts tenant related information (such as tenant ID, app ID, etc.) from the incoming context, as well as the full gRPC method name and the current request.

Downstream handlers can then use log.FromContext(ctx) to access and include these enriched fields in their log entries.

func RequestIdHttpForwardResponseOption

func RequestIdHttpForwardResponseOption(
	ctx context.Context,
	w http.ResponseWriter,
	_ proto.Message,
) error

RequestIdHttpForwardResponseOption gets the request ID added in the gRPC context and injects it in the HTTP response

func RequestIdUnary

func RequestIdUnary(
	ctx context.Context,
	req any,
	_ *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

RequestIdUnary injects a request ID in the gRPC context

Types

type ErrorInterceptor

type ErrorInterceptor struct {
	// contains filtered or unexported fields
}

func NewErrorInterceptor

func NewErrorInterceptor(isProd bool) *ErrorInterceptor

func (ErrorInterceptor) Unary

func (i ErrorInterceptor) Unary(
	ctx context.Context,
	req any,
	_ *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

Jump to

Keyboard shortcuts

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