package
Version:
v0.2.0
Opens a new window with list of versions in this module.
Published: Mar 22, 2026
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package resp provides a unified HTTP response format for Gin-based APIs.
Usage:
resp.Ok(c, user)
resp.Fail(c, 40101, "未登录")
resp.Page(c, list, total, page, size)
Error sends a parameter binding error (code 40001).
Fail sends a business error response (HTTP 200, error in code field).
Ok sends a 200 success response with optional data.
Page sends a paginated success response.
type PageData struct {
List any `json:"list"`
Total int64 `json:"total"`
PageSize int `json:"pageSize"`
CurrentPage int `json:"currentPage"`
}
PageData wraps paginated results.
type R struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data any `json:"data,omitempty"`
}
R is the standard API response envelope.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.