Documentation ¶
Index ¶
- func RenderJson(w http.ResponseWriter, res ApiResponse)
- type ApiResponse
- func Accepted(data interface{}) ApiResponse
- func BadRequest(err error) ApiResponse
- func ConvertServiceError(err error) ApiResponse
- func CreateValidationErrResponse(errMessages []validation.ValidationError) ApiResponse
- func Created(data interface{}) ApiResponse
- func ErrorResponse(err error, status int) ApiResponse
- func InternalServerError(err error) ApiResponse
- func Ok(data interface{}) ApiResponse
- func PartialContent(data interface{}) ApiResponse
- func RecordNotFoundError(err error, message string) ApiResponse
- func ValidationError(err error) ApiResponse
- type Error
- type Metadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderJson ¶
func RenderJson(w http.ResponseWriter, res ApiResponse)
Types ¶
type ApiResponse ¶
type ApiResponse struct { Code int `json:"-"` Data interface{} `json:"data,omitempty"` Metadata Metadata `json:"metadata,omitempty"` Headers map[string]string `json:"-"` Errors interface{} `json:"errors,omitempty"` }
func ConvertServiceError ¶
func ConvertServiceError(err error) ApiResponse
func CreateValidationErrResponse ¶
func CreateValidationErrResponse(errMessages []validation.ValidationError) ApiResponse
func ErrorResponse ¶
func ErrorResponse(err error, status int) ApiResponse
ErrorResponse Custom error response
func InternalServerError ¶
func InternalServerError(err error) ApiResponse
500 Internal server error
func PartialContent ¶
func PartialContent(data interface{}) ApiResponse
PartialContent 206-Partial Content with data in body
func RecordNotFoundError ¶
func RecordNotFoundError(err error, message string) ApiResponse
func ValidationError ¶
func ValidationError(err error) ApiResponse
ValidationError 422-Unprocessable Enttity
func (ApiResponse) AddMetadata ¶
func (a ApiResponse) AddMetadata(m Metadata) ApiResponse
type Error ¶
type Error struct { Message string `json:"message,omitempty"` Code string `json:"code,omitempty"` StatusCode int `json:"status_code,omitempty"` Errors []validation.ValidationError `json:"errors,omitempty"` }
Click to show internal directories.
Click to hide internal directories.