server

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisableAccessLog = func(config *serverConfig) {
	config.disableAccessLog = true
}
View Source
var DisableHealthCheck = func(debugAPI *DebugAPI) {
	debugAPI.enableHealthCheck = false
}
View Source
var DisableMethodNotAllowedHandler = func(config *serverConfig) {
	config.disableMethodNotAllowedHandler = true
}
View Source
var DisableMetrics = func(debugAPI *DebugAPI) {
	debugAPI.enableMetrics = false
}
View Source
var DisableNotFoundHandler = func(config *serverConfig) {
	config.disableNotFoundHandler = true
}
View Source
var DisablePprof = func(debugAPI *DebugAPI) {
	debugAPI.enablePprof = false
}
View Source
var DisableRecovery = func(config *serverConfig) {
	config.disableRecovery = true
}

Functions

func AccessLogSkipPath

func AccessLogSkipPath(regex string) serverOpt

func Address

func Address(address string) serverOpt

func AppName

func AppName(appName string) debugAPIOpt

func AppVersion

func AppVersion(appVersion string) debugAPIOpt

func ApplyDebugAPIProperties

func ApplyDebugAPIProperties(properties *DebugAPIProperties) debugAPIOpt

func ApplyProperties

func ApplyProperties(properties *Properties) serverOpt

func HealthCheckHandler

func HealthCheckHandler(handler HealthCheckHandlerFunc) debugAPIOpt

func OnShutdown

func OnShutdown(callback func()) serverOpt

func ShutdownTimeout

func ShutdownTimeout(timeout time.Duration) serverOpt

Types

type DebugAPI

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

func NewDebugAPI

func NewDebugAPI(opts ...debugAPIOpt) *DebugAPI

func (*DebugAPI) Register

func (debugAPI *DebugAPI) Register(engine *gin.Engine)

type DebugAPIProperties

type DebugAPIProperties struct {
	DisableMetrics     bool   `json:"disableMetrics" yaml:"disableMetrics"`
	DisablePprof       bool   `json:"disablePprof" yaml:"disablePprof"`
	DisableHealthcheck bool   `json:"disableHealthcheck" yaml:"disableHealthcheck"`
	AppName            string `json:"appName" yaml:"appName"`
	AppVersion         string `json:"appVersion" yaml:"appVersion"`
}

type Endpoint

type Endpoint interface {
	Register(*gin.Engine)
}

func CreateEndpoint

func CreateEndpoint(method, path string, handlers ...gin.HandlerFunc) Endpoint

type HealthCheckHandlerFunc

type HealthCheckHandlerFunc = func() bool

type Properties

type Properties struct {
	Address                        string `json:"address" yaml:"address"`
	ShutdownTimeout                int64  `json:"shutdownTimeout" yaml:"shutdownTimeout"`
	DisableRecovery                bool   `json:"disableRecovery" yaml:"disableRecovery"`
	DisableAccessLog               bool   `json:"disableAccessLog" yaml:"disableAccessLog"`
	AccessLogSkipPaths             string `json:"accessLogSkipPaths" yaml:"accessLogSkipPaths"`
	DisableMethodNotAllowedHandler bool   `json:"disableMethodNotAllowedHandler" yaml:"disableMethodNotAllowedHandler"`
	DisableNotFoundHandler         bool   `json:"disableNotFoundHandler" yaml:"disableNotFoundHandler"`
}

type Server

type Server struct {
	Engine     *gin.Engine
	HttpServer *http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...serverOpt) *Server

func (*Server) RegisterEndpoints

func (server *Server) RegisterEndpoints(endpoints ...Endpoint)

func (*Server) StartAndBlock

func (server *Server) StartAndBlock()

Jump to

Keyboard shortcuts

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