Documentation
¶
Index ¶
- Variables
- func Error(r *ghttp.Request, err error, data ...interface{})
- func Middleware(r *ghttp.Request)
- func MiddlewareWithDataHandler(hs ...DataHandler) ghttp.HandlerFunc
- func Success(r *ghttp.Request, data ...interface{})
- func WriteData(r *ghttp.Request, ec *Code, data ...interface{})
- func WriteJSON(r *ghttp.Request, ec *Code)
- type Code
- func (c *Code) Clone() *Code
- func (c *Code) Code() int
- func (c *Code) Detail() interface{}
- func (c *Code) Error() string
- func (c *Code) Message() string
- func (c *Code) Status() int
- func (c *Code) WithCode(code int) *Code
- func (c *Code) WithDetail(detail interface{}) *Code
- func (c *Code) WithHttpStatus(status int) *Code
- func (c *Code) WithMessage(message string) *Code
- type DataHandler
- type JSON
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CodeDefaultSuccess = NewCode(0, "success", http.StatusOK) CodeDefaultFailure = NewCode(500, "failed", http.StatusInternalServerError) CodeInvalidParameter = NewCode(400, "invalid parameter", http.StatusBadRequest) CodePermissionDeny = NewCode(403, "permission deny", http.StatusForbidden) CodeNotFound = NewCode(404, "not found", http.StatusNotFound) CodeConflict = NewCode(409, "resource conflict", http.StatusConflict) CodeTooManyRequests = NewCode(429, "too many requests", http.StatusTooManyRequests) CodeLocked = NewCode(423, "resource locked", http.StatusLocked) CodeUnImplemented = NewCode(501, "not implemented", http.StatusNotImplemented) CodeBadGateway = NewCode(502, "bad gateway", http.StatusBadGateway) CodeGatewayTimeout = NewCode(504, "gateway timeout", http.StatusGatewayTimeout) )
common code define, using biz code from 0-1000
Functions ¶
func Middleware ¶
func MiddlewareWithDataHandler ¶
func MiddlewareWithDataHandler(hs ...DataHandler) ghttp.HandlerFunc
Types ¶
type Code ¶
type Code struct {
// contains filtered or unexported fields
}
func CodeFromError ¶
func CodeFromHttpStatus ¶
func DefaultFailure ¶
func DefaultFailure() *Code
func DefaultSuccess ¶
func DefaultSuccess() *Code
func (*Code) WithDetail ¶
func (*Code) WithHttpStatus ¶
func (*Code) WithMessage ¶
Click to show internal directories.
Click to hide internal directories.