Documentation
¶
Index ¶
- Variables
- func ParseHttpResponse(resp interface{}) (int, interface{})
- type ErrorResponse
- type MetaResponse
- type ResponseSuccess
- type RestError
- func NewHttpBadRequest(errors []string, payload any) RestError
- func NewHttpConflict(errors []string) RestError
- func NewHttpError(code int, message string, errors []string, payload any) RestError
- func NewHttpForbidden(errors []string) RestError
- func NewHttpInternalServerError(message string) RestError
- func NewHttpNotFound(errors []string, payload any) RestError
- func NewHttpTooManyRequest(errors []string) RestError
- func NewHttpUnauthorized(errors []string, payload any) RestError
- func NewHttpUnprocessedEntity(errors []string) RestError
- func NewHttpValidationError(payload any) RestError
- func NewParseSQLError(err error) RestError
- func NewParseSQLUniqueError(err error) RestError
- func ParseHttpError(err error) RestError
- type SuccessResponse
- func (e SuccessResponse) ResponseCode() int
- func (e SuccessResponse) ResponseData() interface{}
- func (e SuccessResponse) ResponseErrors() bool
- func (e SuccessResponse) ResponseMessage() string
- func (e SuccessResponse) ResponseMeta() MetaResponse
- func (e SuccessResponse) ResponsePayload() interface{}
- func (e SuccessResponse) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInternalServerError = "internal server error" ErrNotFound = "not found" ErrBadRequest = "bad request" ErrForbidden = "forbidden" ErrTooManyRequest = "too many request" ErrConflict = "conflict" ErrUnprocessEntity = "unprocessable entity" )
Functions ¶
func ParseHttpResponse ¶
func ParseHttpResponse(resp interface{}) (int, interface{})
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Meta MetaResponse `json:"meta"`
Errors []string `json:"errors"`
Payload interface{} `json:"payload,omitempty"`
}
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
func (ErrorResponse) ResponseCode ¶
func (e ErrorResponse) ResponseCode() int
func (ErrorResponse) ResponseErrors ¶
func (e ErrorResponse) ResponseErrors() []string
func (ErrorResponse) ResponseMessage ¶
func (e ErrorResponse) ResponseMessage() string
func (ErrorResponse) ResponseMeta ¶
func (e ErrorResponse) ResponseMeta() MetaResponse
func (ErrorResponse) ResponsePayload ¶
func (e ErrorResponse) ResponsePayload() any
type MetaResponse ¶
type ResponseSuccess ¶
type ResponseSuccess interface {
ResponseCode() int
ResponseData() interface{}
ResponseErrors() bool
ResponseMessage() string
ResponsePayload() interface{}
ResponseMeta() MetaResponse
}
func NewHttpCreated ¶
func NewHttpCreated(data interface{}) ResponseSuccess
func NewHttpOK ¶
func NewHttpOK(data interface{}) ResponseSuccess
type RestError ¶
type RestError interface {
error
ResponseMeta() MetaResponse
ResponseCode() int
ResponseErrors() []string
ResponseMessage() string
ResponsePayload() any
}
func NewHttpBadRequest ¶
func NewHttpConflict ¶
func NewHttpError ¶
func NewHttpForbidden ¶
func NewHttpNotFound ¶
func NewHttpTooManyRequest ¶
func NewHttpUnauthorized ¶
func NewHttpValidationError ¶
func NewParseSQLError ¶
func NewParseSQLUniqueError ¶
type SuccessResponse ¶
type SuccessResponse struct {
Meta MetaResponse `json:"meta"`
Error bool `json:"error"`
Payload interface{} `json:"payload,omitempty"`
Data interface{} `json:"data,omitempty"`
}
func (SuccessResponse) ResponseCode ¶
func (e SuccessResponse) ResponseCode() int
func (SuccessResponse) ResponseData ¶
func (e SuccessResponse) ResponseData() interface{}
func (SuccessResponse) ResponseErrors ¶
func (e SuccessResponse) ResponseErrors() bool
func (SuccessResponse) ResponseMessage ¶
func (e SuccessResponse) ResponseMessage() string
func (SuccessResponse) ResponseMeta ¶
func (e SuccessResponse) ResponseMeta() MetaResponse
func (SuccessResponse) ResponsePayload ¶
func (e SuccessResponse) ResponsePayload() interface{}
func (SuccessResponse) String ¶
func (e SuccessResponse) String() string
Click to show internal directories.
Click to hide internal directories.