grpc_validator

package
v0.0.0-...-53c1a21 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamServerInterceptor

func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new streaming server interceptor that validates incoming messages.

If `all` is false, the interceptor returns first validation error. Otherwise the interceptor returns ALL validation error as a wrapped multi-error. Note that generated codes prior to protoc-gen-validate v0.6.0 do not provide an all-validation interface. In this case the interceptor fallbacks to legacy validation and `all` is ignored. The stage at which invalid messages will be rejected with `InvalidArgument` varies based on the type of the RPC. For `ServerStream` (1:m) requests, it will happen before reaching any userspace handlers. For `ClientStream` (n:1) or `BidiStream` (n:m) RPCs, the messages will be rejected on calls to `stream.Recv()`.

func UnaryClientInterceptor

func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor

UnaryClientInterceptor returns a new unary client interceptor that validates outgoing messages.

Invalid messages will be rejected with `InvalidArgument` before sending the request to server. If `all` is false, the interceptor returns first validation error. Otherwise the interceptor returns ALL validation error as a wrapped multi-error. Note that generated codes prior to protoc-gen-validate v0.6.0 do not provide an all-validation interface. In this case the interceptor fallbacks to legacy validation and `all` is ignored.

func UnaryServerInterceptor

func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor that validates incoming messages.

Invalid messages will be rejected with `InvalidArgument` before reaching any userspace handlers. If `all` is false, the interceptor returns first validation error. Otherwise the interceptor returns ALL validation error as a wrapped multi-error. Note that generated codes prior to protoc-gen-validate v0.6.0 do not provide an all-validation interface. In this case the interceptor fallbacks to legacy validation and `all` is ignored.

Types

type Option

type Option func(o *option)

func WithAll

func WithAll(all bool) Option

func WithErrTransformer

func WithErrTransformer(fn func(error) error) Option

Jump to

Keyboard shortcuts

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