response

package
v0.0.0-...-39f3c58 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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 OK

func OK(w http.ResponseWriter)

OK writes an empty response with status code 200.

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.

func SetCookie

func SetCookie(w http.ResponseWriter, name, value string, maxAge int)

SetCookie sets a cookie in the response.

func Text

func Text(w http.ResponseWriter, status int, v string)

Text writes a text response with the given status code and value.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL