Documentation
¶
Index ¶
- func DecodeRequestIntoStruct(w http.ResponseWriter, r *http.Request, dest interface{}) error
- func ReturnError(w http.ResponseWriter, err error, httpStatus int)
- func ReturnInternalServerError(w http.ResponseWriter, code, message string)
- func ReturnRawError(w http.ResponseWriter, code, message string, status int)
- func ReturnResponseToClient(w http.ResponseWriter, value interface{})
- func ReturnResponseToClientWithStatus(w http.ResponseWriter, value interface{}, httpStatus int)
- func SendResponse(w http.ResponseWriter, statusCode int, success bool, message string, ...)
- type APIResponse
- type ErrorDTO
- type Meta
- type Pagination
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeRequestIntoStruct ¶
func DecodeRequestIntoStruct(w http.ResponseWriter, r *http.Request, dest interface{}) error
func ReturnError ¶
func ReturnError(w http.ResponseWriter, err error, httpStatus int)
func ReturnInternalServerError ¶
func ReturnInternalServerError(w http.ResponseWriter, code, message string)
func ReturnRawError ¶
func ReturnRawError(w http.ResponseWriter, code, message string, status int)
Returns a Raw error writting the code and the message received
func ReturnResponseToClient ¶
func ReturnResponseToClient(w http.ResponseWriter, value interface{})
func ReturnResponseToClientWithStatus ¶
func ReturnResponseToClientWithStatus(w http.ResponseWriter, value interface{}, httpStatus int)
func SendResponse ¶ added in v0.1.3
func SendResponse(w http.ResponseWriter, statusCode int, success bool, message string, data interface{}, errors interface{}, pagination *Pagination)
SendResponse envía una respuesta JSON con la estructura común
Types ¶
type APIResponse ¶ added in v0.1.3
type APIResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
Errors interface{} `json:"errors,omitempty"`
Meta Meta `json:"meta"`
}
APIResponse es la estructura común para todas las respuestas
type ErrorDTO ¶
type ErrorDTO struct {
Code string `json:"code"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
}
func NewErrorDTO ¶
NewErrorDTO returns a new ErrorDTO
type Meta ¶ added in v0.1.3
type Meta struct {
Timestamp string `json:"timestamp"`
RequestID string `json:"requestId,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
}
Meta contains additional metadatadata
Click to show internal directories.
Click to hide internal directories.