server

package
v0.0.0-...-f5948c0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGrpcWebServer

func NewGrpcWebServer(grpcServer *grpc.Server) *web.WrappedGrpcServer

func SetAccessLog

func SetAccessLog(accessLog AccessLog)

func Start

func Start(s *Server)
func Start(config *ServerConfig, ginhandle func(*gin.Engine), grpchandle func(*grpc.Server), grpcoptions []grpc.ServerOption, gatewayregist gateway.GatewayHandle, graphqlresolve graphql.ExecutableSchema) {
	NewServer(config, ginhandle, grpchandle, grpcoptions, gatewayregist, graphqlresolve).Start()
}

func StreamAccess

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

func UnaryAccess

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

func Validator

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

Types

type AccessLog

type AccessLog = func(ctxi *http_context.Context, url, method, body, result string, code int)

type ConvertContext

type ConvertContext func(r *http.Request) *http_context.Context

type CustomContext

type CustomContext func(c context.Context, r *http.Request) context.Context

type Http3Config

type Http3Config struct {
	Address  string
	CertFile string
	KeyFile  string
}

type Server

type Server struct {
	Config *ServerConfig
	// Grpc options
	GRPCOptions []grpc.ServerOption
	// 注册 grpc 服务
	GRPCHandle func(*grpc.Server)
	// 注册 grpc-gateway 服务
	GatewayRegistr gateway.GatewayHandle
	// 注册 gin 服务
	GinHandle func(engine *gin.Engine)
	// 注册 graphql 服务
	GraphqlResolve graphql.ExecutableSchema
}

func NewServer

func NewServer(config *ServerConfig, ginhandle func(*gin.Engine), grpchandle func(*grpc.Server), grpcoptions []grpc.ServerOption, gatewayregist gateway.GatewayHandle, graphqlresolve graphql.ExecutableSchema) *Server

func (*Server) Serve

func (s *Server) Serve()

func (*Server) Start

func (s *Server) Start()

type ServerConfig

type ServerConfig struct {
	Protocol                        string
	Domain                          string
	Port                            int32
	StaticFs                        []*StaticFsConfig
	ReadTimeout                     time.Duration `expr:"$+5"`
	WriteTimeout                    time.Duration `expr:"$+5"`
	OpenTracing, Prometheus, GenDoc bool
	Gin                             *gini.Config
	GrpcWeb                         bool
	Http3                           *Http3Config
	Cors                            cors.Options
}

func (*ServerConfig) Init

func (c *ServerConfig) Init()

type StaticFsConfig

type StaticFsConfig struct {
	Prefix string
	Root   string
}

Jump to

Keyboard shortcuts

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