Documentation ¶
Index ¶
- Constants
- Variables
- func ForwardedByGrpcGateway(ctx context.Context) bool
- func QueryUnescape(uri string) string
- type ClientInterceptor
- type GatewayInterceptor
- type MessageValidator
- type NotifyHandler
- type Payload
- type ServerInterceptor
- type SessionUserinfo
- type Sign
- type SignatureHandler
- type SignatureIdentifier
- type UserinfoHandler
- type WhitelistingHandler
Constants ¶
const ( // JournalID a random id used by log journal JournalID = "journal-id" // 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" // XForwardedFor forwarded for XForwardedFor = "x-forwarded-for" // XForwardedHost forwarded host XForwardedHost = "x-forwarded-host" )
Variables ¶
var FileDescriptor = &fileDescriptor{ options: make(map[string]protoreflect.ProtoMessage), }
FileDescriptor protobuf file descriptor
var MetricsError = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: namespace, Subsystem: subsystem, Name: "error", Help: "error(s) alert", Buckets: []float64{0.1, 0.3, 0.5, 0.7, 0.9, 1.1}, }, []string{"method", "code", "message", "journal_id"})
MetricsError metrics for alertmanager
var MetricsRequestCost = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: namespace, Subsystem: subsystem, Name: "requestcost", Help: "[ok] request(s) cost seconds", Buckets: []float64{0.1, 0.3, 0.5, 0.7, 0.9, 1.1}, }, []string{"method"})
MetricsRequestCost metrics for ok request cost
var Validator = &validator{ auth: make(map[string]UserinfoHandler), proxyAuth: make(map[string]SignatureHandler), whitelisting: make(map[string]WhitelistingHandler), }
Validator authorization & proxy_authorization validator
Functions ¶
func ForwardedByGrpcGateway ¶
ForwardedByGrpcGateway whether forwarded by grpc gateway
func QueryUnescape ¶
Types ¶
type ClientInterceptor ¶
type ClientInterceptor struct {
// contains filtered or unexported fields
}
ClientInterceptor the client's interceptor
func NewClientInterceptor ¶
func NewClientInterceptor(sign Sign, logger *zap.Logger, notify NotifyHandler) *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(logger *zap.Logger, notify NotifyHandler) *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 MessageValidator ¶
type MessageValidator interface {
Valid() error
}
MessageValidator generated by bluekaki/pkg/protoc-gen-message-validator
type NotifyHandler ¶ added in v1.1.3
type NotifyHandler func(alert *errors.AlertMessage)
type Payload ¶
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(logger *zap.Logger, enablePrometheus bool, notify NotifyHandler) *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 SignatureHandler ¶ added in v1.1.3
type SignatureIdentifier ¶
type SignatureIdentifier struct{}
SignatureIdentifier mark identifier in context