server

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 45 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAccessLog

func SetAccessLog(accessLog AccessLog)

func Start

func Start(s *Server)
func Start(config *Config, 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 Config added in v1.6.0

type Config struct {
	Http        http.Server
	Http2       http2.Server
	Http3       *http3.Server `json:"http3,omitempty"`
	StopTimeout time.Duration
	CertFile    string            `json:"cert_file,omitempty"`
	KeyFile     string            `json:"key_file,omitempty"`
	StaticFs    []*StaticFsConfig `json:"static_fs,omitempty"`
	Gin         *gin.Engine       `json:"gin,omitempty"`
	EnableCors  bool
	Cors        *cors.Options `json:"cors"`
	// Grpc options
	GRPCOptions               []grpc.ServerOption
	EnableGrpcWeb             bool
	GrpcWebOption             []web.Option `json:"grpc_web,omitempty"`
	Trace, Prometheus, GenDoc bool
}

func (*Config) InitAfterInject added in v1.6.0

func (c *Config) InitAfterInject()

func (*Config) InitBeforeInject added in v1.6.0

func (c *Config) InitBeforeInject()

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 Server

type Server struct {
	Config *Config
	// 注册 grpc 服务
	GRPCHandle func(*grpc.Server)
	// 注册 grpc-gateway 服务
	GatewayHandle gateway.GatewayHandle
	// 注册 gin 服务
	GinHandle func(engine *gin.Engine)
	// 注册 graphql 服务
	GraphqlHandle graphql.ExecutableSchema
}

func NewServer

func NewServer(config *Config, ginhandle func(*gin.Engine), grpchandle func(*grpc.Server), gatewayregist gateway.GatewayHandle, graphqlresolve graphql.ExecutableSchema) *Server

func (*Server) Serve

func (s *Server) Serve()

func (*Server) Start

func (s *Server) Start()

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