server

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func CORS(c *gin.Context)

CORS 跨域中间件

func Recover

func Recover() gin.HandlerFunc

func RequestLog

func RequestLog() gin.HandlerFunc

func Trace

func Trace(traceHeader string) gin.HandlerFunc

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn websocket connection

func (*Conn) Push

func (c *Conn) Push(msg []byte) error

Push send message to client

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

func NewHTTPServer

func NewHTTPServer(addr string) *HTTPServer

func (*HTTPServer) EnableAvailableHealthCheck

func (server *HTTPServer) EnableAvailableHealthCheck() *HTTPServer

EnableAvailableHealthCheck enables the health check

func (*HTTPServer) EnableCorsMiddleware

func (server *HTTPServer) EnableCorsMiddleware() *HTTPServer

EnableCorsMiddleware enables cors middleware

func (*HTTPServer) EnablePprofHandler

func (server *HTTPServer) EnablePprofHandler() *HTTPServer

EnablePprofHandler enables the profiler for the http server

func (*HTTPServer) EnableReleaseMode

func (server *HTTPServer) EnableReleaseMode() *HTTPServer

EnableReleaseMode enables the release mode for the http server,it will hide the route tables

func (*HTTPServer) EnableSwaggerHandler

func (server *HTTPServer) EnableSwaggerHandler() *HTTPServer

EnableSwaggerHandler enables the swagger handler for the http server

func (*HTTPServer) EnableTraceMiddleware

func (server *HTTPServer) EnableTraceMiddleware(traceHeader string) *HTTPServer

EnableTraceMiddleware enables trace middleware with trace header name

func (*HTTPServer) RegisterRouteLoader

func (server *HTTPServer) RegisterRouteLoader(loader func(router *gin.Engine)) *HTTPServer

RegisterRouteLoader registers a route loader

func (*HTTPServer) Serve

func (server *HTTPServer) Serve(stop <-chan struct{})

func (*HTTPServer) Shutdown

func (server *HTTPServer) Shutdown()

Shutdown shuts down the server.

func (*HTTPServer) WithDefaultRecoverMiddleware

func (server *HTTPServer) WithDefaultRecoverMiddleware() *HTTPServer

WithDefaultRecoverMiddleware enables default recover middleware

func (*HTTPServer) WithDefaultRequestLogMiddleware

func (server *HTTPServer) WithDefaultRequestLogMiddleware() *HTTPServer

WithDefaultRequestLogMiddleware enables the default request log middleware.

func (*HTTPServer) WithNotFoundHandler

func (server *HTTPServer) WithNotFoundHandler(notFoundHandler ...gin.HandlerFunc) *HTTPServer

WithNotFoundHandler provide the handler for not found routes and methods

type RPCServer

type RPCServer struct {
	// contains filtered or unexported fields
}

func NewGRPCServer

func NewGRPCServer(bind string) *RPCServer

func (*RPCServer) RegisterService

func (server *RPCServer) RegisterService(register func(s *grpc.Server)) *RPCServer

RegisterService registers grpc service

func (*RPCServer) Serve

func (server *RPCServer) Serve(stop <-chan struct{})

Serve start grpc listener

func (*RPCServer) Shutdown

func (server *RPCServer) Shutdown()

Shutdown shuts down the server.

func (*RPCServer) WithChainUnaryInterceptor

func (server *RPCServer) WithChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) *RPCServer

WithChainUnaryInterceptor sets the interceptors.It must be called before RegisterService.

func (*RPCServer) WithKeepAliveParams

func (server *RPCServer) WithKeepAliveParams(kp keepalive.ServerParameters) *RPCServer

WithKeepAliveParams sets the KeepAlive option.It must be called before RegisterService.

func (*RPCServer) WithOptions

func (server *RPCServer) WithOptions(opts ...grpc.ServerOption) *RPCServer

WithOptions sets the options for the RPC server.It must be called before RegisterService.

type Schema

type Schema struct {
	Protocol string
	Bind     string
}

type Server

type Server interface {
	Serve(stop <-chan struct{})
}

type WebSocketServer

type WebSocketServer struct {
	// contains filtered or unexported fields
}

WebSocketServer provide the websocket server.

func NewWebSocketServer

func NewWebSocketServer(bind string) *WebSocketServer

func (*WebSocketServer) OnConnect

func (server *WebSocketServer) OnConnect(handler func(conn Conn)) *WebSocketServer

OnConnect is set callback when the connection is established

func (*WebSocketServer) OnDisconnect

func (server *WebSocketServer) OnDisconnect(handler func(conn Conn)) *WebSocketServer

OnDisconnect is set callback when the client disconnects from the server

func (*WebSocketServer) OnMessage

func (server *WebSocketServer) OnMessage(handler func(conn Conn, msg []byte)) *WebSocketServer

OnMessage is set callback when a message is received.

func (*WebSocketServer) Serve

func (server *WebSocketServer) Serve(stop <-chan struct{})

Serve start websocket server

func (*WebSocketServer) Shutdown

func (server *WebSocketServer) Shutdown()

Shutdown stop websocket server.

Jump to

Keyboard shortcuts

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