server

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApiOptions struct {
		flags.Options
		Environment       string `short:"e" long:"env" description:"Use ApiServer environment" default:"testing"`
		Version           bool   `short:"v" long:"verbose"  description:"Show ApiServer version"`
		EnablePProfile    bool   `short:"p" long:"enable-pprof"  description:"enable pprof"`
		PProfilePort      int    `short:"d" long:"pprof-port"  description:"pprof port" default:"8188"`
		EnableHealthCheck bool   `short:"a" long:"enable-health-check"  description:"enable health check"`
		HealthCheckURI    string `short:"i" long:"health-check-uri"  description:"health check uri" default:"/health" `
		HealthCheckPort   int    `short:"f" long:"health-check-port"  description:"health check port" default:"8186"`
		ConfigFileName    string `short:"c" long:"config" description:"Use ApiServer config file" default:"main"`
		EnableDevMode     bool   `short:"m" long:"enable-dev-mode"  description:"enable dev mode"`
	}
)

Functions

This section is empty.

Types

type ApiServer

type ApiServer struct {
	Engine     *gin.Engine
	HttpServer *http.Server
	Addr       string

	Routers     []func(*gin.Engine)
	Middlewares []func(*gin.Engine)
	Shutdowns   []func(*ApiServer)
	Services    []func(*ApiServer)
	// contains filtered or unexported fields
}

func NewApiServer

func NewApiServer(opts ...Option) (*ApiServer, error)

func (*ApiServer) ListenAndServe

func (srv *ApiServer) ListenAndServe() error

ListenAndServe Listen And Serve()

func (*ApiServer) RegisterMiddleware

func (srv *ApiServer) RegisterMiddleware(middlewares ...func(engine *gin.Engine))

Register Middleware Middleware

func (*ApiServer) RegisterRouters

func (srv *ApiServer) RegisterRouters(routers ...func(engine *gin.Engine)) *ApiServer

RegisterRouters

func (*ApiServer) RegisterService

func (srv *ApiServer) RegisterService(handlers ...func(*ApiServer))

Register Service Handler

func (*ApiServer) RegisterShutdown

func (srv *ApiServer) RegisterShutdown(handlers ...func(*ApiServer))

Register Shutdown Handler

func (*ApiServer) Shutdown

func (srv *ApiServer) Shutdown(ctx context.Context)

type Option

type Option func(c *common.Config)

func WithEtcd

func WithEtcd() Option

注册etcd服务

func WithMysql

func WithMysql() Option

注册mysql服务

func WithNotify added in v1.0.1

func WithNotify() Option

注册通知服务

func WithRedis

func WithRedis() Option

注册redis服务

Jump to

Keyboard shortcuts

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