Documentation
¶
Index ¶
- func ResponesFILE(c *gin.Context, filename string)
- func ResponseBytes(c *gin.Context, responder Responder, data ...[]byte)
- func ResponseBytesList(c *gin.Context, responder Responder, total int64, data ...[]byte)
- func ResponseDATA(c *gin.Context, data []byte, headers ...map[string]string)
- func ResponseJSON(c *gin.Context, responder Responder, data ...any)
- func ResponseTEXT(c *gin.Context, responder Responder, data ...any)
- type Code
- type CodeInstance
- type Responder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResponesFILE ¶
func ResponseBytesList ¶
Types ¶
type Code ¶
type Code int32
const ( CodeInvalidParam Code = 1000 + iota CodeBadRequest CodeInvalidToken CodeNeedLogin CodeNetworkTimeout CodeContextTimeout CodeTooManyRequests CodeNotFound CodeForbidden CodeAlreadyExist )
通用状态码
const ( CodeInvalidLogin Code = 2000 + iota CodeInvalidSignup CodeOldPasswordNotMatch CodeNewPasswordNotMatch CodeNotFoundQueryID CodeNotFoundRouteParam CodeNotFoundUser CodeNotFoundUserID CodeAlreadyExistsUser CodeAlreadyExistsRole CodeTooLargeFile )
业务状态码
func (Code) WithErr ¶
func (r Code) WithErr(err error) CodeInstance
func (Code) WithMsg ¶
func (r Code) WithMsg(msg string) CodeInstance
func (Code) WithStatus ¶
func (r Code) WithStatus(status int) CodeInstance
type CodeInstance ¶
type CodeInstance struct {
// contains filtered or unexported fields
}
CodeInstance 表示一个错误码实例,包含自定义的状态和消息
func (CodeInstance) Code ¶
func (ci CodeInstance) Code() int
func (CodeInstance) Msg ¶
func (ci CodeInstance) Msg() string
func (CodeInstance) Status ¶
func (ci CodeInstance) Status() int
func (CodeInstance) WithErr ¶
func (ci CodeInstance) WithErr(err error) CodeInstance
func (CodeInstance) WithMsg ¶
func (ci CodeInstance) WithMsg(msg string) CodeInstance
func (CodeInstance) WithStatus ¶
func (ci CodeInstance) WithStatus(status int) CodeInstance
Click to show internal directories.
Click to hide internal directories.