Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInternalServer = errors.New("internal server error")
ErrInternalServer is a generic internal server error.
Functions ¶
func RequestMW ¶
RequestMW is a middleware that creates a request id for each request and sets it on the header field X-Request-Id. Also logs the start and end of each request.
func RespondError ¶
RespondError sends an error response with a status code. The error is automatically logged for you. If the error implements StatusCoder, the provided status code will be used.
Types ¶
type Response ¶
type Response struct { Results interface{} `json:"results,omitempty"` Errors []ResponseError `json:"errors,omitempty"` }
Response is the format used for all the responses.
type ResponseError ¶
type ResponseError struct {
Message string `json:"message"`
}
ResponseError is the format used for response errors.
func (ResponseError) Error ¶
func (a ResponseError) Error() string
Error implements the error interface
Click to show internal directories.
Click to hide internal directories.