server

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugMode indicates server mode is debug.
	DebugMode = "debug"
	// ReleaseMode indicates server mode is release.
	ReleaseMode = "release"
	// TestMode indicates server mode is test.
	TestMode = "test"
)

Variables

This section is empty.

Functions

func GracefulShutdown

func GracefulShutdown(server *http.Server, quit <-chan os.Signal, done chan<- struct{}, conf ...*section.Config)

GracefulShutdown 优雅关闭服务器

func Mode

func Mode() string

Mode returns currently server mode.

func SetMode

func SetMode(mode string)

SetMode 设置服务模式

Types

type Configurator

type Configurator func(*Server)

Configurator 服务器配置

func WithRelease

func WithRelease() Configurator

WithRelease release模式

type Module added in v0.1.2

type Module interface {
	RegisterModule(s *Server)
}

Module 服务器模块

type RouteParams

type RouteParams struct {
	dig.In
	Routes []route.RouteInfo `group:"route"`
}

type Server

type Server struct {
	*gin.Engine
}

func Default

func Default() *Server

Default 默认服务器

func New

func New() *Server

New 初始化服务器 func New(rp RouteParams, cs ...Configurator) *Server {

func NewWithModules added in v0.1.2

func NewWithModules(ms []Module) *Server

NewWithModules 使用模块初始化服务器

func (*Server) Configure

func (s *Server) Configure(cs ...Configurator) *Server

Configure 配置

func (*Server) HttpServer

func (s *Server) HttpServer(conf *section.Config) *http.Server

HttpServer 标准Http服务器

func (*Server) RegisterRoute

func (s *Server) RegisterRoute(rs ...route.Route) *Server

RegisterRoutes 注册路由

func (*Server) RegisterRouteInfo

func (s *Server) RegisterRouteInfo(rs ...route.RouteInfo) *Server

RegisterRoutes 注册路由信息

Jump to

Keyboard shortcuts

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