Documentation ¶
Index ¶
Constants ¶
const ( ErrorMissingNameParameter = 1 ErrorInvalidIdParameter = 2 ErrorInvalidEnumParameter = 3 ErrorInvalidLimitParameter = 4 ErrorInvalidOffsetParameter = 5 )
Custom error details
It is suggested you actually type the int value here, as opposed to using the iota pattern generally used with constants. These integer values actually have meaning, and API consumers are to use the values. Using actual ints will prevent accidental value changes in the event something is inserted in the middle of the list. In addition, this makes it easier to lookup what an error code means from it's int value.
After adding a value to this list, you must always add it to the errorDetailText map.
Variables ¶
This section is empty.
Functions ¶
func ErrorDetailText ¶
ErrorText returns a code's associated error text
Types ¶
type ErrorDetail ¶
type Response ¶
type Response struct { Context echo.Context `json:"-"` Success bool `json:"success"` StatusCode int `json:"status_code"` StatusText string `json:"status_text"` ErrorDetails []ErrorDetail `json:"error_details"` Content interface{} `json:"content"` }
func New ¶
New instantiates a new Response struct and attaches the Echo context. It returns the Response struct.
func (*Response) AddErrorDetail ¶
AddError appends an error to the response via an Error Code.
func (*Response) AddErrorDetails ¶
AddErrorDetails appends multiple errors to the response via Error Codes.
func (*Response) Render ¶
func (r *Response) Render()
Render sets the appropriate status, converts the content to JSON and passes it to Echo's context for rendering.
func (*Response) SetResponse ¶
SetResponse sets the response status code and content.