Documentation
¶
Index ¶
- func Fail(w http.ResponseWriter, r *http.Request, code int, args ...any)
- func Ok(w http.ResponseWriter, r *http.Request, args ...any)
- func Out(w http.ResponseWriter, r *http.Request, code int, args ...any)
- type CoderMessager
- type Done
- type Error
- type Failure
- type FieldError
- type FieldMessager
- type Messager
- type ResultData
- type ResultID
- type ResultOk
- type ViewPatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CoderMessager ¶
CoderMessager get message and code with http request
type Done ¶
type Done struct {
Code int `json:"status" example:"0"` // 状态值,0=ok
Time int64 `json:"t,omitempty"` // 时间戳
Result any `json:"result,omitempty"` // 主体数据,可选
Extra any `json:"extra,omitempty"` // 附加数据,可选
}
Done 操作成功返回的结构
type Error ¶
type Error struct {
Code int `json:"status" example:"1"` // 错误代码,可选
Message string `json:"message" example:"错误信息"` // 错误信息
Field string `json:"field,omitempty" example:"错误字段"` // 错误字段,可选,多用于表单校验
}
Error ...
type Failure ¶
type Failure struct {
Code int `json:"status" example:"1"` // 状态值
Time int64 `json:"t,omitempty"` // 时间戳
Message string `json:"message" example:"错误信息"` // 错误信息
Field string `json:"field,omitempty" example:"错误字段"` // 错误字段,可选,多用于表单校验
}
Failure 出现错误,返回相关的错误码和消息文本
type FieldError ¶
FieldError a error with field, for validator
type FieldMessager ¶
FieldMessager a error with field
type ResultData ¶
type ResultData struct {
Data any `json:"data,omitempty"` // 数据集数组
Total int `json:"total,omitempty"` // 符合条件的总记录数
}
ResultData 特定数据集(带JSON数组和总数),一般用在分页查询结果
func (*ResultData) PatchView ¶
func (dr *ResultData) PatchView()
Click to show internal directories.
Click to hide internal directories.