web

package
v1.0.4-snapshot Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SuccessResponse 成功响应对象
	SuccessResponse = BaseResponse{Code: errs.Success.Code, Message: errs.Success.Message}

	// SystemErrResponse 系统异常
	SystemErrResponse = BaseResponse{Code: errs.ErrSystem.Code, Message: errs.ErrSystem.Message}
)
View Source
var GinWebRouter *gin.Engine

GinWebRouter Gin的web路由器

Functions

func BindAndValidate

func BindAndValidate(c *gin.Context, req interface{}) bool

BindAndValidate 绑定请求参数并校验,失败时打印原始参数和错误 参数:c Gin上下文,req 待绑定的结构体指针 返回:true=校验通过,false=校验失败(已自动返回错误响应)

func CreateGinServer

func CreateGinServer(contextPath string) *gin.Engine

func InitWebServer

func InitWebServer(ctx context.Context, webGroups []config.WebGroup, validatorMap map[string]validator.Func, webMiddlewares ...gin.HandlerFunc)

InitWebServer 启动Web服务

func WrapSuccessResponse

func WrapSuccessResponse(resp *BaseResponse)

Types

type AppConfigLoadedEventListener

type AppConfigLoadedEventListener struct{}

func (*AppConfigLoadedEventListener) GetOrder

func (ace *AppConfigLoadedEventListener) GetOrder() int

func (*AppConfigLoadedEventListener) OnApplicationEvent

func (ace *AppConfigLoadedEventListener) OnApplicationEvent(ctx context.Context, event *listener.AppConfigLoadedEvent)

type AppShutDownEventListener

type AppShutDownEventListener struct{}

func (*AppShutDownEventListener) GetOrder

func (l *AppShutDownEventListener) GetOrder() int

func (*AppShutDownEventListener) OnApplicationEvent

func (l *AppShutDownEventListener) OnApplicationEvent(ctx context.Context, event *listener.AppShutdownEvent)

type BaseResponse

type BaseResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func WrapBizError

func WrapBizError(err *errs.BizError) *BaseResponse

WrapBizError 包装现有错误为业务错误

type GinHandlerFunc

type GinHandlerFunc struct {
	Method string
	Path   string
	Func   gin.HandlerFunc
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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