Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found"}
Functions ¶
func ErrInvalidRequest ¶
Types ¶
type ErrResponse ¶
type ErrResponse struct { Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code StatusText string `json:"status"` // user-level status message AppCode int64 `json:"code,omitempty"` // application-specific error code ErrorText string `json:"error,omitempty"` // application-level error message, for debugging }
ErrResponse renderer type for handling all sorts of errors.
In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
type UserRequest ¶
func (*UserRequest) Bind ¶
func (ur *UserRequest) Bind(r *http.Request) error
Bind validates required fields and values
func (*UserRequest) UnmarshalJSON ¶
func (ur *UserRequest) UnmarshalJSON(data []byte) error
type UserResponse ¶
func NewUserResponse ¶
func NewUserResponse(user usermodel.User) *UserResponse
func (*UserResponse) Render ¶
func (ur *UserResponse) Render(w http.ResponseWriter, r *http.Request) error
Click to show internal directories.
Click to hide internal directories.