Documentation
¶
Index ¶
- Constants
- type Response
- func BadGateway(msg ...string) Response[any]
- func BadRequest(msg ...string) Response[any]
- func Conflict(msg ...string) Response[any]
- func Fail(code int, message string) Response[any]
- func Forbidden(msg ...string) Response[any]
- func GatewayTimeout(msg ...string) Response[any]
- func InternalServerError(msg ...string) Response[any]
- func MethodNotAllowed(msg ...string) Response[any]
- func NotFound(msg ...string) Response[any]
- func NotImplemented(msg ...string) Response[any]
- func RequestTimeout(msg ...string) Response[any]
- func ServiceUnavailable(msg ...string) Response[any]
- func Success[T any](data T) Response[T]
- func TooManyRequests(msg ...string) Response[any]
- func Unauthorized(msg ...string) Response[any]
Constants ¶
View Source
const ( // 成功 CodeSuccess = 0 // 客户端错误(4xx) CodeBadRequest = 400 CodeForbidden = 403 CodeNotFound = 404 CodeMethodNotAllowed = 405 CodeRequestTimeout = 408 CodeConflict = 409 CodeTooManyRequests = 429 // 服务端错误(5xx) CodeInternalServerError = 500 CodeNotImplemented = 501 CodeBadGateway = 502 CodeGatewayTimeout = 504 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
type Response[T any] struct { Code int `json:"code"` Message string `json:"message"` Data T `json:"data"` }
ResponseWithData 用来在Swagger里指定Data的具体类型
func BadGateway ¶
func BadRequest ¶
func GatewayTimeout ¶
func InternalServerError ¶
func MethodNotAllowed ¶
func NotImplemented ¶
func RequestTimeout ¶
func ServiceUnavailable ¶
func TooManyRequests ¶
func Unauthorized ¶
Click to show internal directories.
Click to hide internal directories.