Documentation ¶
Index ¶
- Variables
- func BadRequest(w http.ResponseWriter, err error)
- func BadRequestf(w http.ResponseWriter, format string, a ...interface{})
- func ErrorCode(w http.ResponseWriter, err error, status int)
- func Forbidden(w http.ResponseWriter, err error)
- func InternalError(w http.ResponseWriter, err error)
- func InternalErrorf(w http.ResponseWriter, format string, a ...interface{})
- func JSON(w http.ResponseWriter, v interface{}, status int)
- func NotFound(w http.ResponseWriter, err error)
- func NotFoundf(w http.ResponseWriter, format string, a ...interface{})
- func NotImplemented(w http.ResponseWriter, err error)
- func Unauthorized(w http.ResponseWriter, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidToken is returned when the api request token is invalid. ErrInvalidToken = errors.New("Invalid or missing token") ErrUnauthorized = errors.New("Unauthorized") // ErrForbidden is returned when user access is forbidden. ErrForbidden = errors.New("Forbidden") // ErrNotFound is returned when a resource is not found. ErrNotFound = errors.New("Not Found") // ErrNotImplemented is returned when an endpoint is not implemented. ErrNotImplemented = errors.New("Not Implemented") )
Functions ¶
func BadRequest ¶
func BadRequest(w http.ResponseWriter, err error)
BadRequest writes the json-encoded error message to the response with a 400 bad request status code.
func BadRequestf ¶
func BadRequestf(w http.ResponseWriter, format string, a ...interface{})
BadRequestf writes the json-encoded error message to the response with a 400 bad request status code.
func ErrorCode ¶
func ErrorCode(w http.ResponseWriter, err error, status int)
ErrorCode writes the json-encoded error message to the response.
func Forbidden ¶
func Forbidden(w http.ResponseWriter, err error)
Forbidden writes the json-encoded error message to the response with a 403 forbidden status code.
func InternalError ¶
func InternalError(w http.ResponseWriter, err error)
InternalError writes the json-encoded error message to the response with a 500 internal server error.
func InternalErrorf ¶
func InternalErrorf(w http.ResponseWriter, format string, a ...interface{})
InternalErrorf writes the json-encoded error message to the response with a 500 internal server error.
func JSON ¶
func JSON(w http.ResponseWriter, v interface{}, status int)
JSON writes the json-encoded error message to the response with a 400 bad request status code.
func NotFound ¶
func NotFound(w http.ResponseWriter, err error)
NotFound writes the json-encoded error message to the response with a 404 not found status code.
func NotFoundf ¶
func NotFoundf(w http.ResponseWriter, format string, a ...interface{})
NotFoundf writes the json-encoded error message to the response with a 404 not found status code.
func NotImplemented ¶
func NotImplemented(w http.ResponseWriter, err error)
NotImplemented writes the json-encoded error message to the response with a 501 not found status code.
func Unauthorized ¶
func Unauthorized(w http.ResponseWriter, err error)
Unauthorized writes the json-encoded error message to the response with a 401 unauthorized status code.
Types ¶
This section is empty.