v1.0.8 Latest Latest

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 29 Imported by: 0




This section is empty.


This section is empty.


func GRPCHandlerFunc

func GRPCHandlerFunc(g *grpc.Server, h http.Handler) http.Handler

GRPCHandlerFunc for request dispatch

func GetClientIP

func GetClientIP(ctx context.Context) (string, error)

GetClientIP export

func GetTLSConfig

func GetTLSConfig(pemPath, keyPath string) *tls.Config

GetTLSConfig for tls

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.


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

func (*BaseServer) Start

func (s *BaseServer) Start(opts ...Option)

Start gRPC server

type Option

type Option func(options *Options)

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

type Pagination interface {
	GetPage() int32
	GetSize() int32
	GetOrder() string
	GetOrderBy() string

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

type RecoveryHandlerFuncContext func(ctx context.Context, p interface{}) (err error)

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.

type Register

type Register interface {
	RegisterGRPC(g *grpc.Server)
	RegisterHTTP(c context.Context, gwmux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error

Register for gRPC service register

Jump to

Keyboard shortcuts

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