Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrIncorrectBody error ErrIncorrectBody = xerrors.New("Incorrect body") // ErrIncorectFormFields error ErrIncorectFormFields = xerrors.New("Incorrect form fields") )
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, response JSONErrorResponse)
Error writes error response
func Unauthorized ¶
func Unauthorized(w http.ResponseWriter)
Unauthorized writes unauthorized response
func UnmarshalForm ¶
func UnmarshalForm(w http.ResponseWriter, r *http.Request, to interface{}) error
UnmarshalForm from body and validate it. If error occurs, writes error message to response writer
Types ¶
type APIResponse ¶
type APIResponse interface {
Check()
}
APIResponse struct to prevent incorrect data in response
type JSONErrorResponse ¶
type JSONErrorResponse struct { Status int `json:"status"` Message string `json:"message"` ClientMessage string `json:"client_message"` }
JSONErrorResponse presents general structure of error response
func InternalErrorResponse ¶
func InternalErrorResponse(message string) JSONErrorResponse
InternalErrorResponse template with custom message
Click to show internal directories.
Click to hide internal directories.