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 any)
- func ResponseWithCreated(ctx *gin.Context, data any)
- func ResponseWithErrors(ctx *gin.Context, statusCode, subCode int, errors []any)
- func ResponseWithOK(ctx *gin.Context, data any)
- func ResponseWithSuccess(ctx *gin.Context, statusCode int, data any)
- 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
Types ¶
type Description ¶
func HttpCodeDescription ¶
func HttpCodeDescription(code int) Description
HttpCodeDescription returns the description of the http code.
type Meta ¶
type Meta struct { Code int `json:"code"` Type string `json:"type,omitempty"` Message string `json:"message,omitempty"` Errors []any `json:"errors,omitempty"` }
type Response ¶
type Response struct { Meta Meta `json:"meta"` Data any `json:"data"` // contains filtered or unexported fields }
func UnmarshalResponse ¶
UnmarshalResponse create response
func (*Response) StatusCode ¶
StatusCode return http status code in response's meta
Click to show internal directories.
Click to hide internal directories.