server

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APICfg

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

type AccessLogCfg

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

type AdminCfg

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

type Config

type Config struct {
	API           *APICfg            `mapstructure:"api"`
	Admin         *AdminCfg          `mapstructure:"admin"`
	OpenTelemetry *tracing.OTLConfig `mapstructure:"opentelemetry"`
	AccessLog     AccessLogCfg       `mapstructure:"access_log"`
	Shutdown      time.Duration      `mapstructure:"shutdown"`
}

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