Documentation ¶
Index ¶
- Variables
- func Build(ctx *fiber.Ctx, ce CustomResponse)
- type CustomResponse
- func (e CustomResponse) Error() string
- func (e CustomResponse) WithData(data interface{}) CustomResponse
- func (e CustomResponse) WithDetail(detail string) CustomResponse
- func (e CustomResponse) WithError(err error) CustomResponse
- func (e CustomResponse) WithErrorInfo(errInfo []ErrorInfo) CustomResponse
- func (e CustomResponse) WithPagination(data interface{}, page int, perPage int, total int) CustomResponse
- func (e CustomResponse) WithValidationError(err error) CustomResponse
- type ErrorInfo
- type ListResponse
- type MetaResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInternalServer = CustomResponse{ HttpCode: http.StatusInternalServerError, Message: "internal server error", Code: "5000", } ErrBadRequest = CustomResponse{ HttpCode: http.StatusBadRequest, Message: "bad request", Code: "4000", } HttpCode: http.StatusUnauthorized, Message: "Api-Key invalid", Code: "4001", } ErrInvalidParam = CustomResponse{ HttpCode: http.StatusBadRequest, Message: "invalid parameter", Code: "4003", } ErrForbidden = CustomResponse{ HttpCode: http.StatusForbidden, Message: http.StatusText(http.StatusForbidden), Code: "4003", } ErrRecordNotFound = CustomResponse{ HttpCode: http.StatusNotFound, Message: "record not found", Code: "4004", } ErrUnprocessableEntity = CustomResponse{ HttpCode: http.StatusUnprocessableEntity, Message: "StatusUnprocessableEntity", Code: "4002", } StatusTooManyRequests = CustomResponse{ HttpCode: http.StatusTooManyRequests, Message: "StatusTooManyRequests", Code: "4005", } )
View Source
var ( Ok = CustomResponse{ HttpCode: http.StatusOK, Message: "success", Code: "0000", } SuccessMessage = "success" )
Functions ¶
func Build ¶
func Build(ctx *fiber.Ctx, ce CustomResponse)
Types ¶
type CustomResponse ¶
type CustomResponse struct { HttpCode int `json:"http_code"` Message string `json:"message"` Code string `json:"code"` Detail string `json:"detail,omitempty"` Data interface{} `json:"data,omitempty"` Pagination interface{} `json:"pagination,omitempty"` Errors []ErrorInfo `json:"errors,omitempty"` }
func (CustomResponse) Error ¶
func (e CustomResponse) Error() string
func (CustomResponse) WithData ¶
func (e CustomResponse) WithData(data interface{}) CustomResponse
func (CustomResponse) WithDetail ¶
func (e CustomResponse) WithDetail(detail string) CustomResponse
func (CustomResponse) WithError ¶
func (e CustomResponse) WithError(err error) CustomResponse
func (CustomResponse) WithErrorInfo ¶
func (e CustomResponse) WithErrorInfo(errInfo []ErrorInfo) CustomResponse
func (CustomResponse) WithPagination ¶
func (e CustomResponse) WithPagination(data interface{}, page int, perPage int, total int) CustomResponse
func (CustomResponse) WithValidationError ¶
func (e CustomResponse) WithValidationError(err error) CustomResponse
type ListResponse ¶
type ListResponse struct { Meta MetaResponse `json:"meta"` Data interface{} `json:"data"` }
Click to show internal directories.
Click to hide internal directories.