server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Version   = "v1.1.0"
	ApiModule = "common/api-server"
)

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 *config.Config)

func WithEtcd

func WithEtcd() Option

func WithMysql

func WithMysql() Option

func WithRedis

func WithRedis() Option

Jump to

Keyboard shortcuts

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