interceptor

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Authorization used by auth, both gateway and grpc
	Authorization = "authorization"
	// ProxyAuthorization used by signature, both gateway and grpc
	ProxyAuthorization = "proxy-authorization"
	// Date GMT format
	Date = "date"
	// Method http.XXXMethod
	Method = "method"
	// URI url encoded
	URI = "uri"
	// Body string body
	Body = "body"
)
View Source
const (
	// JournalID a random id used by log journal
	JournalID = "journal_id"
)

Variables

This section is empty.

Functions

func ForwardedByGrpcGateway

func ForwardedByGrpcGateway(ctx context.Context) bool

ForwardedByGrpcGateway whether forwarded by grpc gateway

Types

type ClientInterceptor

type ClientInterceptor struct {
}

ClientInterceptor the client's interceptor

func NewClientInterceptor

func NewClientInterceptor() *ClientInterceptor

NewClientInterceptor create a client interceptor

func (*ClientInterceptor) StreamInterceptor

func (c *ClientInterceptor) StreamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (stream grpc.ClientStream, err error)

StreamInterceptor a interceptor for client stream operations

func (*ClientInterceptor) UnaryInterceptor

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

UnaryInterceptor a interceptor for client unary operations

type GatewayInterceptor

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

GatewayInterceptor the gateway's interceptor

func NewGatewayInterceptor

func NewGatewayInterceptor(checkAuthHeader bool) *GatewayInterceptor

NewGatewayInterceptor create a gateway interceptor

func (*GatewayInterceptor) UnaryInterceptor

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

UnaryInterceptor a interceptor for gateway unary operations

type Payload added in v0.1.3

type Payload interface {
	JournalID() string
	ForwardedByGrpcGateway() bool
	Service() string
	Date() string
	Method() string
	URI() string
	Body() string
	// contains filtered or unexported methods
}

Payload rest or grpc payload

type ServerInterceptor

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

ServerInterceptor the server's interceptor

func NewServerInterceptor

func NewServerInterceptor(verifyToken VerifyToken, logger *zap.Logger) *ServerInterceptor

NewServerInterceptor create a server interceptor

func (*ServerInterceptor) StreamInterceptor

func (s *ServerInterceptor) StreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error)

StreamInterceptor a interceptor for server stream operations

func (*ServerInterceptor) UnaryInterceptor

func (s *ServerInterceptor) UnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

UnaryInterceptor a interceptor for server unary operations

type VerifyToken

type VerifyToken func(auth, proxyAuth string, payload Payload) bool

VerifyToken verify token legality

Jump to

Keyboard shortcuts

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