propagation

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MiddlewareName = "propagation"
)

Variables

This section is empty.

Functions

func WithPropagationType

func WithPropagationType(pt principal.PropagationType) options.Option

WithPropagationType sets the propagation type for the principal.

Types

type Middleware

type Middleware struct {
	*Options
}

Middleware is a Kratos middleware for principal propagation. It embeds the Options struct to hold its configuration.

func New

func New(opts ...options.Option) *Middleware

New is a convenience function for creating a new principal propagation middleware.

func (*Middleware) Client

func (m *Middleware) Client() middleware.KMiddleware

Client implements the Kratos middleware for client-side principal propagation. It extracts the Principal from the context, encodes it, and injects it into the outgoing request's metadata (for gRPC) or headers (for HTTP).

func (*Middleware) Server

func (m *Middleware) Server() middleware.KMiddleware

Server implements the Kratos middleware for server-side principal extraction. It extracts an encoded principal from the incoming request, decodes it, and injects it into the context. This allows downstream middleware (like authz) to act on the propagated principal.

type Options

type Options struct {
	// PropagationType determines how the principal is propagated (e.g., via gRPC metadata or HTTP headers).
	PropagationType principal.PropagationType
}

Options holds the configuration for the principal middleware.

Jump to

Keyboard shortcuts

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