Documentation ¶
Index ¶
- func BadRequest(w http.ResponseWriter, err error)
- func BadRequestf(w http.ResponseWriter, format string, a ...any)
- func Conflict(w http.ResponseWriter, err error)
- func CopyResponse(dest http.ResponseWriter, src *http.Response) (written int64, err error)
- func Error(w http.ResponseWriter, err error, status int)
- func Forbidden(w http.ResponseWriter, err error)
- func Forbiddenf(w http.ResponseWriter, format string, a ...any)
- func InternalError(w http.ResponseWriter, err error)
- func InternalErrorCommon(w http.ResponseWriter)
- func JSON(w http.ResponseWriter, v interface{}, status int) error
- func NotFound(w http.ResponseWriter, err error)
- func Unauthorized(w http.ResponseWriter, err error)
- func Unauthorizedf(w http.ResponseWriter, format string, a ...any)
- type ErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(w http.ResponseWriter, err error)
BadRequest writes the json encoded error message to the response with 400 bad request status code.
func BadRequestf ¶
func BadRequestf(w http.ResponseWriter, format string, a ...any)
BadRequest writes the json encoded error message to the response with 400 bad request status code.
func Conflict ¶
func Conflict(w http.ResponseWriter, err error)
Conflict writes the json encoded error message to the response with 409 conflict status code.
func CopyResponse ¶
CopyResponse writes a http response to the response by copying the header, status code and the body.
func Error ¶
func Error(w http.ResponseWriter, err error, status int)
Error 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 403 forbidden error status code.
func Forbiddenf ¶
func Forbiddenf(w http.ResponseWriter, format string, a ...any)
Forbiddenf writes the json encoded error message to the response with 403 forbidden error status code.
func InternalError ¶
func InternalError(w http.ResponseWriter, err error)
InternalError writes the json encoded error message to the response with 500 internal server error status code.
func InternalErrorCommon ¶
func InternalErrorCommon(w http.ResponseWriter)
InternalError writes the json encoded error message to the response with 500 internal server error status code.
func JSON ¶
func JSON(w http.ResponseWriter, v interface{}, status int) error
JSON writes the json-encoded data to the response with a given status code.
func NotFound ¶
func NotFound(w http.ResponseWriter, err error)
NotFound writes the json encoded error message to the response with 404 not found status code.
func Unauthorized ¶
func Unauthorized(w http.ResponseWriter, err error)
Unauthorized writes the json encoded error message to the response with 401 unauthorized error status code.
func Unauthorizedf ¶
func Unauthorizedf(w http.ResponseWriter, format string, a ...any)
Unauthorized writes the json encoded error message to the response with 401 unauthorized error status code.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}