Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatusCode ¶
StatusCode is a convenience function for extracting HTTP Status Code from error types. It returns 200 for nil errors, embedded StatusCode for HTTPError instances, and 500 in every other case.
func StatusText ¶
StatusText is a convenience function for extracting HTTP status text from error types.
func Write ¶
func Write(w http.ResponseWriter, err error)
Write to the response writer a status code and a JSON-encoded message based on the provided error. The payload will look like:
{
"message": "error writing to DB"
}
In case the status code is 500 (Internal Server Error), the message will always be "Internal Server Error". Write does not end the request; the caller should ensure no further writes are done to w.
Types ¶
Click to show internal directories.
Click to hide internal directories.