server

package
v0.0.0-...-2eb6bad Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCustomMetricLabel

func SetCustomMetricLabel(c *gin.Context, value string)

SetCustomMetricLabel was used to set the custom metric key in the gin context

Types

type APIConfig

type APIConfig struct {
	Addr     string `mapstructure:"addr" json:"addr"`
	BasePath string `mapstructure:"basepath" json:"base_path"`
}

type AccessLogConfig

type AccessLogConfig struct {
	Enabled bool   `mapstructure:"enabled"`
	Pattern string `mapstructure:"pattern"`
}

type AdminConfig

type AdminConfig struct {
	Addr     string `mapstructure:"addr" json:"addr"`
	BasePath string `mapstructure:"basepath" json:"base_path"`
}

type Config

type Config struct {
	API                     *APIConfig      `mapstructure:"api"`
	Admin                   *AdminConfig    `mapstructure:"admin"`
	AccessLog               AccessLogConfig `mapstructure:"access_log"`
	GracefulShutdownTimeout time.Duration   `mapstructure:"graceful_shutdown_timeout"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Validate

func (cfg *Config) Validate() error

type Server

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

func New

func New(config *Config, logger *log.Logger) (*Server, error)

New would create server which contains api and admin api server

func (*Server) GetAPIEngine

func (srv *Server) GetAPIEngine() *gin.Engine

func (*Server) GetAPIRouteGroup

func (srv *Server) GetAPIRouteGroup() *gin.RouterGroup

GetAPIRouteGroup return api's gin engine that user can add api handlers

func (*Server) GetAdminEngine

func (srv *Server) GetAdminEngine() *gin.Engine

func (*Server) GetAdminRouteGroup

func (srv *Server) GetAdminRouteGroup() *gin.RouterGroup

GetAdminRouteGroup return admin's gin engine that user can add admin handlers

func (*Server) Run

func (srv *Server) Run() error

Run would setup api/admin api server and async listening on api ports

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP uses to parse request from http.Server

func (*Server) Shutdown

func (srv *Server) Shutdown() error

Shutdown would graceful shutdown the api server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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