Documentation ¶
Index ¶
- Variables
- func SendJSON(w http.ResponseWriter, payload interface{}, statusCode int) error
- type Error
- type ErrorPayload
- type Response
- func Accepted(payload interface{}) Response
- func BadRequest(err error, payload ErrorPayload) Response
- func Conflict(err error, payload ErrorPayload) Response
- func Created(payload interface{}) Response
- func ErrorResponse(err error) Response
- func InternalServerError(err error) Response
- func NoContent() Response
- func NotFound(err error, payload ErrorPayload) Response
- func NotImplemented(err error) Response
- func OK(payload interface{}) Response
- func Unauthorized(err error, payload ErrorPayload) Response
- func UnprocessableEntity(err error, payload ErrorPayload) Response
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInternalServerError = ErrorPayload{Error: Error{Code: "error:internal_server_error", Description: "Internal Server Error"}} ErrInvalidBody = ErrorPayload{Error: Error{Code: "error:invalid_body", Description: "Invalid body"}} ErrInvalidParams = ErrorPayload{Error: Error{Code: "error:invalid_parameters", Description: "Invalid query parameters"}} ErrNotImplemented = ErrorPayload{Error: Error{Code: "error:not_implemented", Description: "Not implemented"}} )
shared
View Source
var ( ErrAccountNotFound = ErrorPayload{Error: Error{Code: "error:account_not_found", Description: "Account not found"}} ErrInsufficientBalance = ErrorPayload{Error: Error{Code: "error:insufficient_balance", Description: "Insufficient balance"}} ErrInsufficientCredit = ErrorPayload{Error: Error{Code: "error:insufficient_credit", Description: "Insufficient credit"}} ErrInvalidAccID = ErrorPayload{Error: Error{Code: "error:invalid_account_id", Description: "Account id must be a UUIDv4"}} ErrInvalidAmount = ErrorPayload{Error: Error{Code: "error:invalid_amount", Description: "Amount must be greater than 0"}} ErrInvalidOperation = ErrorPayload{Error: Error{Code: "error:invalid_operation", Description: "Invalid operation"}} )
accounts
Functions ¶
Types ¶
type ErrorPayload ¶
type ErrorPayload struct {
Error `json:"errors"`
}
ErrorPayload represents error response payload
type Response ¶
type Response struct { Status int Error error Payload interface{} // contains filtered or unexported fields }
Response represents an API response
func UnprocessableEntity ¶
func UnprocessableEntity(err error, payload ErrorPayload) Response
UnprocessableEntity 422
Click to show internal directories.
Click to hide internal directories.