Help us shape the future of Go! Take the 2026 Go Developer Survey

interceptor

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HubVersionHeader = "hub-version"
)

Variables

View Source
var (
	LastSeenServerVersion                  string
	ErrorTranslationUnaryServerInterceptor = func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
		resp, err = handler(ctx, req)
		return resp, TranslateError(err)
	}
	ErrorTranslationStreamServerInterceptor = func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
		return TranslateError(handler(srv, ss))
	}
)

Functions

func GetVersionHeaderClientUnaryInterceptor

func GetVersionHeaderClientUnaryInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

GetVersionHeaderClientUnaryInterceptor returns a new unary client interceptor that extracts the argo-version from the response and sets the global variable LastSeenServerVersion

func LoggingStreamServerInterceptor

func LoggingStreamServerInterceptor() grpc.StreamServerInterceptor

func LoggingUnaryServerInterceptor

func LoggingUnaryServerInterceptor() grpc.UnaryServerInterceptor

func PanicLoggerStreamServerInterceptor

func PanicLoggerStreamServerInterceptor() grpc.StreamServerInterceptor

PanicLoggerStreamServerInterceptor returns a new streaming server interceptor for recovering from panics and returning error

func PanicLoggerUnaryServerInterceptor

func PanicLoggerUnaryServerInterceptor() grpc.UnaryServerInterceptor

PanicLoggerUnaryServerInterceptor returns a new unary server interceptor for recovering from panics and returning error

func RatelimitStreamServerInterceptor

func RatelimitStreamServerInterceptor(ratelimiter limiter.Store) grpc.StreamServerInterceptor

RatelimitStreamServerInterceptor returns a new stream server interceptor that performs rate limiting on the request.

func RatelimitUnaryServerInterceptor

func RatelimitUnaryServerInterceptor(ratelimiter limiter.Store) grpc.UnaryServerInterceptor

RatelimitUnaryServerInterceptor returns a new unary server interceptor that performs request rate limiting.

func SetVersionHeaderStreamServerInterceptor

func SetVersionHeaderStreamServerInterceptor(version string) grpc.StreamServerInterceptor

SetVersionHeaderStreamServerInterceptor returns a new stream server interceptor that sets the argo-version header

func SetVersionHeaderUnaryServerInterceptor

func SetVersionHeaderUnaryServerInterceptor(version string) grpc.UnaryServerInterceptor

SetVersionHeaderUnaryServerInterceptor returns a new unary server interceptor that sets the argo-version header

func StreamAuthInterceptor

func StreamAuthInterceptor(tokenOpe token.Operator, userSvc user.Service) grpc.StreamServerInterceptor

func StreamAuthzInterceptor

func StreamAuthzInterceptor(authSvc auth.Service, userRepo user.Repository, catalog *apicatalog.Catalog) grpc.StreamServerInterceptor

StreamAuthzInterceptor creates a new stream server interceptor for authorization

func StreamValidateInterceptor

func StreamValidateInterceptor(validator Validator) grpc.StreamServerInterceptor

StreamValidateInterceptor validates each message a client streams.

func TranslateError

func TranslateError(err error) error

func UnaryAuthInterceptor

func UnaryAuthInterceptor(tokenOpe token.Operator, userSvc user.Service) grpc.UnaryServerInterceptor

func UnaryAuthzInterceptor

func UnaryAuthzInterceptor(authSvc auth.Service, userRepo user.Repository, catalog *apicatalog.Catalog) grpc.UnaryServerInterceptor

UnaryAuthzInterceptor creates a new unary server interceptor for authorization

func UnaryValidateInterceptor

func UnaryValidateInterceptor(validator Validator) grpc.UnaryServerInterceptor

UnaryValidateInterceptor rejects a request that breaks its own constraints.

Validation used to be wherever a handler or use case happened to remember it, which meant an empty username or a malformed email reached Keycloak and a list request could ask for any number of rows. Enforcing the proto's rules in one place makes the definition the contract: what the .proto says is what the server accepts, and `hub api describe` can show a caller the same rules before they send anything.

It runs after authorization, so an unauthorised caller cannot use the difference between InvalidArgument and PermissionDenied to probe the shape of an endpoint they may not reach.

Types

type Validator

type Validator = protovalidate.Validator

Validator checks a request against the constraints its .proto declares.

It is protovalidate's own interface rather than a narrowed one, so the interceptors can be handed a real validator without an adapter and a test can substitute a stub.

func NewValidator

func NewValidator() (Validator, error)

NewValidator builds the protovalidate validator the interceptors use. It compiles every constraint in the registered descriptors up front, so a malformed rule is a startup failure rather than a surprise on the first request that reaches it.

Jump to

Keyboard shortcuts

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