Documentation
¶
Index ¶
- func MakeMessageFunc(c *gin.Context, service, method string) (req proto.Message, resp proto.Message, err error)
- func Response(c *gin.Context, httpStatus int, response *ResponseResult)
- func ResponseError(c *gin.Context, httpStatus int, err error)
- func ResponseSuccess(c *gin.Context, data any)
- type MakeMessageHandler
- type Options
- type ResponseResult
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeMessageFunc ¶
func MakeMessageFunc(c *gin.Context, service, method string) (req proto.Message, resp proto.Message, err error)
通用消息构造逻辑,前提是已经import了pb代码,如:import _ "github.com/fixkme/protoc-gen-gom/example/pbout/go/game"
func ResponseSuccess ¶
Types ¶
type MakeMessageHandler ¶
type Options ¶
type Options struct {
// 版本号,可以为空
ApiVersion string
// Middlewares 里可以添加鉴权的逻辑
Middlewares []gin.HandlerFunc
// 构造消息的方法, 必须提供
MakeMessage MakeMessageHandler
}
type ResponseResult ¶
type ResponseResult struct {
Ecode int `json:"ecode"` // 业务状态码,0为成功,其他表示失败
Error string `json:"error"` // 业务消息提示,不参与逻辑,仅用于ui展示,默认为空字符串
Data interface{} `json:"data"` // 业务数据,如果不设置时默认为json空对象{}
}
返回格式
Click to show internal directories.
Click to hide internal directories.