Documentation ¶
Index ¶
- Constants
- type Response
- func BuildLoginUserResponse(user models.User, token string, code int) Response
- func BuildRegisterUserResponse(user models.User, code int) Response
- func CheckLogin() Response
- func DBErr(msg string, err error) Response
- func Err(errCode int, msg string, err error) Response
- func ParamErr(msg string, err error) Response
- func TokenGetCheck() Response
- type TrackedErrorResponse
- type User
Constants ¶
View Source
const ( // CodeCheckLogin 未登录 CodeCheckLogin = 401 // CodeNoRightErr 未授权访问 CodeNoRightErr = 403 // CodeDBError 数据库操作失败 CodeDBError = 50001 // CodeEncryptError 加密失败 CodeEncryptError = 50002 //CodeParamErr 各种奇奇怪怪的参数错误 CodeParamErr = 40001 //toekn TokenError = 40002 )
三位数错误编码为复用http原本含义 五位数错误编码为应用自定义错误 五开头的五位数错误编码为服务器端错误,比如数据库操作失败 四开头的五位数错误编码为客户端错误,有时候是客户端代码写错了,有时候是用户操作错误
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
type Response struct { Code int `json:"code"` Data interface{} `json:"data,omitempty"` Msg string `json:"msg"` Error string `json:"error,omitempty"` }
Response 基础序列化器
func BuildLoginUserResponse ¶
func BuildRegisterUserResponse ¶
BuildUserResponse 序列化用户响应
func TokenGetCheck ¶
func TokenGetCheck() Response
type TrackedErrorResponse ¶
TrackedErrorResponse 有追踪信息的错误响应
Click to show internal directories.
Click to hide internal directories.