webserver

package
v1.0.1-rel-01 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: AFL-3.0 Imports: 20 Imported by: 0

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 {
	WebGroupPath string

	FuncId       string
	Method       HttpMethod
	RelativePath string
	Handler      gin.HandlerFunc `json:"-"`
}

func NewWebHandler

func NewWebHandler() *WebHandler

func (*WebHandler) Check

func (w *WebHandler) Check() error

type WebHandlers

type WebHandlers []WebHandler

func MergeHandler

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

func (*WebHandlers) Check

func (this *WebHandlers) Check() error

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

https://zhuanlan.zhihu.com/p/678423547

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 (self *WebServer) HandleErr(err error, c *gin.Context)

func (*WebServer) ShowInfo

func (self *WebServer) ShowInfo()

func (*WebServer) StartWeb

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

func (*WebServer) StartWebSwagger

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

func (*WebServer) WebRecover

func (self *WebServer) WebRecover()

错误恢复

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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