Documentation ¶
Index ¶
- func RegisterCustomCode(code int, status, message string) error
- func ResponseError(ctx *gin.Context, statusCode int, err error)
- func ResponseWithAccepted(ctx *gin.Context, data interface{})
- func ResponseWithCreated(ctx *gin.Context, data interface{})
- func ResponseWithErrors(ctx *gin.Context, statusCode, subCode int, errors []interface{})
- func ResponseWithOK(ctx *gin.Context, data interface{})
- func ResponseWithSuccess(ctx *gin.Context, statusCode int, data interface{})
- type Description
- type Meta
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCustomCode ¶
RegisterCustomCode was used to register the custom code description, it would overwrite the previous one when conflicted.
func ResponseError ¶
ResponseError would write the error data output with status error
func ResponseWithAccepted ¶
ResponseWithAccepted would write the success data output with status accepted
func ResponseWithCreated ¶
ResponseWithCreated would write the success data output with status created
func ResponseWithErrors ¶
ResponseWithErrors would write meta with error and empty data
func ResponseWithOK ¶
ResponseWithOK would write the success data output with status ok
func ResponseWithSuccess ¶
ResponseWithSuccess would write the success data output and status into http writer
Types ¶
type Description ¶
func CodeDescription ¶
func CodeDescription(code int) Description
type Meta ¶
type Meta struct { Code int `json:"code"` Type string `json:"type,omitempty"` Message string `json:"message,omitempty"` Errors []interface{} `json:"errors,omitempty"` }
type Response ¶
type Response struct { Meta Meta `json:"meta"` Data interface{} `json:"data"` // contains filtered or unexported fields }
func UnmarshalResponse ¶
UnmarshalResponse create response
func (*Response) Errors ¶
func (r *Response) Errors() []interface{}
Errors return errors in response's meta
func (*Response) StatusCode ¶
StatusCode return http status code in response's meta