Documentation
¶
Index ¶
- Constants
- Variables
- func InitGinEngine() *gin.Engine
- func New400Response(msg string, args ...interface{}) error
- func New500Response(msg string, args ...interface{}) error
- func NewResponse(code, status int, msg string, args ...interface{}) error
- func NoMethodHandler() gin.HandlerFunc
- func NoRouteHandler() gin.HandlerFunc
- func ParseForm(c *gin.Context, obj interface{}) error
- func ParseHeader(c *gin.Context, obj interface{}) error
- func ParseJSON(c *gin.Context, obj interface{}) error
- func ParseParamID(c *gin.Context, key string) int
- func ParseQuery(c *gin.Context, obj interface{}) error
- func ParseUri(c *gin.Context, obj interface{}) error
- func ResError(c *gin.Context, err error, status ...int)
- func ResJSON(c *gin.Context, status int, v interface{})
- func ResSuccess(c *gin.Context, v interface{})
- func Wrap400Response(err error, msg string, args ...interface{}) error
- func Wrap500Response(err error, msg string, args ...interface{}) error
- func WrapResponse(err error, code, status int, msg string, args ...interface{}) error
- type APIException
- type APISuccessResp
- type ResponseError
Constants ¶
View Source
const ( ReqBodyKey = prefix + "/req-body" ResBodyKey = prefix + "/res-body" )
Variables ¶
View Source
var ( ErrInvalidToken = NewResponse(9999, 401, "invalid signature") ErrNoPerm = NewResponse(0, 401, "no permission") ErrNotFound = NewResponse(0, 404, "not found") ErrMethodNotAllow = NewResponse(0, 405, "method not allowed") ErrTooManyRequests = NewResponse(0, 429, "too many requests") ErrInternalServer = NewResponse(0, 500, "internal server error") ErrBadRequest = New400Response("bad request") ErrInvalidParent = New400Response("not found parent node") ErrUserDisable = New400Response("user forbidden") )
Functions ¶
func InitGinEngine ¶
func New400Response ¶
func New500Response ¶
func NewResponse ¶
func NoMethodHandler ¶
func NoMethodHandler() gin.HandlerFunc
func NoRouteHandler ¶
func NoRouteHandler() gin.HandlerFunc
func ParseHeader ¶
func ParseParamID ¶
ParseParamID returns the value of the URL param
func ParseQuery ¶
ParseQuery parameter to struct
func Wrap400Response ¶
func Wrap500Response ¶
Types ¶
type APIException ¶
type APISuccessResp ¶
type ResponseError ¶
type ResponseError struct { Code int // error code Message string Status int // http code Err error }
func UnWrapResponse ¶
func UnWrapResponse(err error) *ResponseError
func (*ResponseError) Error ¶
func (r *ResponseError) Error() string
Click to show internal directories.
Click to hide internal directories.