Documentation
¶
Index ¶
Constants ¶
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.