middleware

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildContextWithNamespace

func BuildContextWithNamespace(ctx context.Context, ns *namespace.Namespace) context.Context

BuildContextWithNamespace stores the namespace in context.

func ChainUnaryInterceptors

func ChainUnaryInterceptors(interceptors ...connect.UnaryInterceptorFunc) connect.Option

ChainUnaryInterceptors chains multiple unary interceptors into a single interceptor.

func ErrorResponse

func ErrorResponse() connect.UnaryInterceptorFunc

ErrorResponse returns a new unary interceptor that standardizes error formatting. It ensures all errors returned from handlers are proper Connect errors. Non-Connect errors are sanitized to prevent leaking internal details.

func FetchNamespaceFromContext

func FetchNamespaceFromContext(ctx context.Context) *namespace.Namespace

FetchNamespaceFromContext retrieves namespace from context, returns default if not found.

func Logger

Logger returns a new unary interceptor that logs request details.

func Namespace

func Namespace(service NamespaceService, namespaceClaimKey, userUUIDHeaderKey string) connect.UnaryInterceptorFunc

Namespace returns a new unary interceptor that extracts namespace from: 1. JWT token (priority 1) - uses namespaceClaimKey 2. x-namespace header (priority 2) 3. Defaults to DefaultNamespace

func Recovery

func Recovery() connect.UnaryInterceptorFunc

Recovery returns a new unary interceptor that recovers from panics.

func UserHeaderCtx

func UserHeaderCtx(identityHeaderKeyUUID, identityHeaderKeyEmail string) connect.UnaryInterceptorFunc

UserHeaderCtx returns a new unary interceptor that propagates a valid user ID from request headers within the request context. Use `user.FromContext` function to get the user.

Types

type NamespaceKey

type NamespaceKey struct{}

NamespaceKey is injected in context with the tenant context

type NamespaceService

type NamespaceService interface {
	GetByID(ctx context.Context, id uuid.UUID) (*namespace.Namespace, error)
	GetByName(ctx context.Context, name string) (*namespace.Namespace, error)
}

Jump to

Keyboard shortcuts

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