Documentation ¶
Overview ¶
Package respondwith contains some helper functions for generating responses in HTTP handlers. Its name is like that because it pairs up with the function names in this package, e.g. "respondwith.ErrorText" or "respondwith.JSON".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorText ¶
func ErrorText(w http.ResponseWriter, err error) bool
ErrorText produces an error response with HTTP status code 500 and Content-Type text/plain if the given error is non-nil. Otherwise, nothing is done and false is returned. Idiomatic usage looks like this:
value, err := thisMayFail() if respondwith.ErrorText(w, err) { return } useValue(value)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.