core

package
v0.2.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnInitialize

func OnInitialize(configFile string, envPrefix string, loadDirs []string, defaultConfigName string)

OnInitialize 设置需要读取的配置文件名、环境变量,并将其内容读取到 viper 中.

func ReadRequest

func ReadRequest(c *gin.Context, rq any, bindFn func(any) error) error

ReadRequest 绑定参数、调用 Default() 初始化,并处理错误.

func ShouldBindJSON

func ShouldBindJSON(c *gin.Context, rq any) error

func ShouldBindQuery

func ShouldBindQuery(c *gin.Context, rq any) error

func ShouldBindUri

func ShouldBindUri(c *gin.Context, rq any) error

func WriteResponse

func WriteResponse(c *gin.Context, result any, err error)

WriteResponse 处理响应的函数.

Types

type ErrorResponse

type ErrorResponse struct {
	// 理由
	Reason string `json:"reason,omitempty"`
	// 信息
	Message string `json:"message,omitempty"`
	// 元数据
	Metadata map[string]string `json:"metadata,omitempty"`
}

ErrorResponse 定义了一个错误响应结构体.

Jump to

Keyboard shortcuts

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