grpcex

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const AllowedHeaderPrefix = "x-"
View Source
const (
	// JsonCodecName is the name registered for the json encoder.
	JsonCodecName = "json"
)

Variables

This section is empty.

Functions

func ContextLoggerStreamServerInterceptor

func ContextLoggerStreamServerInterceptor() grpc.StreamServerInterceptor

func ContextLoggerUnaryServerInterceptor

func ContextLoggerUnaryServerInterceptor() grpc.UnaryServerInterceptor

func DefaultHeaderMatcher

func DefaultHeaderMatcher(key string) (string, bool)

DefaultHeaderMatcher allows header with "x-" prefix

func GetAuthToken

func GetAuthToken(ctx context.Context) (token string)

func GetClientIP

func GetClientIP(ctx context.Context) string

GetClientIP gets client IP from HTTP forward header or GRPC context

func GetHeader

func GetHeader(ctx context.Context, key string) string

GetHeader gets header from GRPC request header or HTTP converted header

func LogRequestStreamServerInterceptor

func LogRequestStreamServerInterceptor() grpc.StreamServerInterceptor

func LogRequestUnaryServerInterceptor

func LogRequestUnaryServerInterceptor() grpc.UnaryServerInterceptor

func RegisterJsonCodec

func RegisterJsonCodec()

func SetZeroLogger

func SetZeroLogger()

func ValidatorStreamServerInterceptor

func ValidatorStreamServerInterceptor() grpc.StreamServerInterceptor

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

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 ValidatorUnaryClientInterceptor

func ValidatorUnaryClientInterceptor() grpc.UnaryClientInterceptor

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

Invalid messages will be rejected with `InvalidArgument` before sending the request to server.

func ValidatorUnaryServerInterceptor

func ValidatorUnaryServerInterceptor() grpc.UnaryServerInterceptor

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

Invalid messages will be rejected with `InvalidArgument` before reaching any userspace handlers.

func WithAuthToken

func WithAuthToken(token string) grpc.CallOption

Types

type AccessController

type AccessController struct {
	// contains filtered or unexported fields
}

func NewAccessController

func NewAccessController(modelFile string, policyFile string) (*AccessController, error)

func (*AccessController) StreamServerInterceptor

func (c *AccessController) StreamServerInterceptor() grpc.StreamServerInterceptor

func (*AccessController) UnaryServerInterceptor

func (c *AccessController) UnaryServerInterceptor() grpc.UnaryServerInterceptor

type TokenAuth

type TokenAuth struct {
	// contains filtered or unexported fields
}

func NewTokenAuth

func NewTokenAuth(token string) *TokenAuth

func (TokenAuth) GetRequestMetadata

func (t TokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error)

func (TokenAuth) RequireTransportSecurity

func (TokenAuth) RequireTransportSecurity() bool

Jump to

Keyboard shortcuts

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