Documentation ¶
Index ¶
- func GRPCHandlerFunc(g *grpc.Server, h http.Handler) http.Handler
- func GetClientIP(ctx context.Context) (string, error)
- func GetTLSConfig(pemPath, keyPath string) *tls.Config
- func StreamServerInterceptor(opts ...RecoveryOption) grpc.StreamServerInterceptor
- func UnaryServerInterceptor(opts ...RecoveryOption) grpc.UnaryServerInterceptor
- type BaseServer
- type Option
- type Options
- type Pagination
- type PaginationParam
- type RecoveryHandlerFunc
- type RecoveryHandlerFuncContext
- type RecoveryOption
- type Register
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GRPCHandlerFunc ¶
GRPCHandlerFunc for request dispatch
func StreamServerInterceptor ¶
func StreamServerInterceptor(opts ...RecoveryOption) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new streaming server interceptor for panic recovery.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(opts ...RecoveryOption) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptor for panic recovery.
Types ¶
type BaseServer ¶
type BaseServer struct { Name string Host string Port int SSLName string SSLCrtFile string SSLKeyFile string // start http server EnableHTTPServer bool // gRPC and http service Services []Register // ignore log gRPC method IgnoreZapLogMethod []string // StreamServerInterceptor for gRPC StreamServerInterceptors []grpc.StreamServerInterceptor // UnaryServerInterceptors for gRPC UnaryServerInterceptors []grpc.UnaryServerInterceptor ServerOptions []grpc.ServerOption // disableAutoRecovery for gRPC StreamServerInterceptor and UnaryServerInterceptor DisableAutoRecovery bool DisableAutoZap bool OnShutdown []func() // contains filtered or unexported fields }
BaseServer for gRPC
type Options ¶
type Options struct { CORSAllowedMethods []string CORSAllowedOrigins []string CORSAllowedHeaders []string UseProtoNames bool EmitUnpopulated bool DiscardUnknown bool UseEnumNumbers bool }
ConnectOptions for hub connection config
type Pagination ¶
Pagination for proto request
type PaginationParam ¶
type PaginationParam struct { Page int `form:"page,default=1" json:"page" binding:"max=100,min=1"` Size int `form:"size,default=10" json:"size" binding:"max=1000,min=1"` Order string `form:"order" json:"order" binding:"lt=32"` OrderBy string `form:"order_by" json:"order_by" binding:"lt=256"` }
PaginationParam for Pagination base params
func BindPagination ¶
func BindPagination(r Pagination) *PaginationParam
BindPagination for proto pagination
type RecoveryHandlerFunc ¶
type RecoveryHandlerFunc func(p interface{}) (err error)
RecoveryHandlerFunc is a function that recovers from the panic `p` by returning an `error`.
type RecoveryHandlerFuncContext ¶
RecoveryHandlerFuncContext is a function that recovers from the panic `p` by returning an `error`. The context can be used to extract request scoped metadata and context values.
type RecoveryOption ¶
type RecoveryOption func(*options)
Option export
func WithRecoveryHandler ¶
func WithRecoveryHandler(f RecoveryHandlerFunc) RecoveryOption
WithRecoveryHandler customizes the function for recovering from a panic.
func WithRecoveryHandlerContext ¶
func WithRecoveryHandlerContext(f RecoveryHandlerFuncContext) RecoveryOption
WithRecoveryHandlerContext customizes the function for recovering from a panic.