Documentation ¶
Index ¶
- func Empty(w http.ResponseWriter, status int)
- func ErrorResponse(w http.ResponseWriter, err error)
- func JSON(w http.ResponseWriter, status int, v any)
- func OK(w http.ResponseWriter)
- func Redirect(w http.ResponseWriter, r *http.Request, url string)
- func RemoveCookie(w http.ResponseWriter, name string)
- func SetCookie(w http.ResponseWriter, name, value string, maxAge int)
- func Text(w http.ResponseWriter, status int, v string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Empty ¶
func Empty(w http.ResponseWriter, status int)
Empty writes an empty response with the given status code.
func ErrorResponse ¶
func ErrorResponse(w http.ResponseWriter, err error)
ErrorResponse writes an error response for the given error. Appropriate http status code will be used based on the error type. Error message will be sent in the http response for applicable errors. If the error is of type base.APIError with not-nil cause, the cause will be logged. If the error is of type base.APIError with not-nil http status code, it will be used. Otherwise, default is 500. Appropriate errors will be logged.
func JSON ¶
func JSON(w http.ResponseWriter, status int, v any)
JSON writes a JSON response with the given status code and value.
func Redirect ¶
func Redirect(w http.ResponseWriter, r *http.Request, url string)
Redirect redirects the request to the given url with status code 302.
func RemoveCookie ¶
func RemoveCookie(w http.ResponseWriter, name string)
RemoveCookie removes a cookie from the response.
Types ¶
This section is empty.