webserver

package
v1.0.2-dev-10 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MulanPSL-2.0 Imports: 20 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CloseCtx = func(ctx *gin.Context) {
	if err := ctx.Request.Body.Close(); err != nil {
		logrus.Errorf("failed to close: %v\n", err)
	}
}

Functions

func RegisterRouter

func RegisterRouter() *[]WebHandler

Types

type FuncSwagger

type FuncSwagger func(router *gin.Engine) *gin.Engine

type FuncWebHandlers

type FuncWebHandlers func() *WebHandlers

func Merge

func Merge(one *WebHandlers, other *WebHandlers) FuncWebHandlers

type HttpMethod

type HttpMethod string

type WebHandler

type WebHandler struct {
	FuncId       string
	Method       HttpMethod
	RelativePath string
	Handler      gin.HandlerFunc
}

func NewWebHandler

func NewWebHandler() *WebHandler

type WebHandlers

type WebHandlers []WebHandler

func MergeHandler

func MergeHandler(one *WebHandlers, other *WebHandlers) *WebHandlers

defer CloseCtx(ctx)

type WebRouters

type WebRouters struct {
	WebHandlers  *WebHandlers
	FuncRegister FuncWebHandlers
	FuncSwagger  FuncSwagger
}

func (*WebRouters) AddRouter

func (this *WebRouters) AddRouter(router *gin.Engine)

func (*WebRouters) BuildRouter

func (this *WebRouters) BuildRouter() *gin.Engine

func (*WebRouters) InstallMiddleWare

func (this *WebRouters) InstallMiddleWare(router *gin.Engine) *gin.Engine

type WebServer

type WebServer struct {
	//服务名称
	ServerName string
	Port       int
	// etcd注册服务器地址  xxx.xxx.xxx.xxx:xx
	EtcdHosts []string
	Registry  registry.Registry

	MetaData   *map[string]string
	ServerInfo string

	FuncSwagger FuncSwagger `json:"-"`
}

func New

func New(serverDto *baseconfig.WebServerDto) *WebServer

func (*WebServer) HandleErr

func (this *WebServer) HandleErr(err error, c *gin.Context)

func (*WebServer) Info

func (this *WebServer) Info()

func (*WebServer) StartWeb

func (this *WebServer) StartWeb(handler FuncWebHandlers) web.Service

func (*WebServer) StartWebSwagger

func (this *WebServer) StartWebSwagger(swagg FuncSwagger, handler FuncWebHandlers) web.Service

func (*WebServer) WebRecover

func (this *WebServer) WebRecover()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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