Documentation ¶
Index ¶
- func DefaultRouter() *fiber.App
- func SendCode(ctx *fiber.Ctx, c code.Code) error
- func SendDataCode[DATA any](ctx *fiber.Ctx, data DATA, c code.Code) error
- func SendDataOk[DATA any](ctx *fiber.Ctx, data DATA) error
- func SendError(ctx *fiber.Ctx, err error) error
- func SendFailed(ctx *fiber.Ctx) error
- func SendJson(ctx *fiber.Ctx, data any) error
- func SendOk(ctx *fiber.Ctx) error
- func SendPageDataOk[DATA any](ctx *fiber.Ctx, data DATA, page, pageSize int, total int64) error
- func SendParamsParseFailed(ctx *fiber.Ctx, failedFields []*FailedField) error
- type BasicResponse
- type DataResponse
- type FailedField
- type PageResponse
- type ParamsParseFailedResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRouter ¶
func DefaultRouter() *fiber.App
func SendDataCode ¶
SendDataCode 并返回数据,并指定 code
func SendDataOk ¶
SendDataOk 请求响应成功,并返回数据
func SendError ¶
SendError 根据 err 确定返回内容 如果 err 为 nil,则返回 Success 如果 err 为 *code.Error,则返回对应的 code 和 msg 如果 err 不为 nil,则返回 Failed
func SendPageDataOk ¶
SendPageDataOk 请求响应成功,并返回分页数据
func SendParamsParseFailed ¶
func SendParamsParseFailed(ctx *fiber.Ctx, failedFields []*FailedField) error
SendParamsParseFailed 返回解析失败的字段信息
Types ¶
type BasicResponse ¶
BasicResponse 基础请求响应
type DataResponse ¶
type DataResponse[DATA any] struct { BasicResponse Data DATA `json:"data"` // 响应数据 }
DataResponse 带响应数据响应
type FailedField ¶
type FailedField struct { FailedField string `json:"failed_field"` // 异常字段 Tag string `json:"tag"` // 验证 tag Value string `json:"value"` // 验证值 }
FailedField 验证失败字段
type PageResponse ¶
type PageResponse[DATA any] struct { Page int `json:"page"` // 当前页 PageSize int `json:"page_size"` // 每页大小 Total int64 `json:"total"` // 总数 Data DATA `json:"data"` // 数据 }
PageResponse 分页查询内层响应
type ParamsParseFailedResponse ¶
type ParamsParseFailedResponse struct { BasicResponse FailedFields []*FailedField `json:"failed_fields"` // 异常字段 }
ParamsParseFailedResponse 参数解析失败响应
Click to show internal directories.
Click to hide internal directories.