response

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func CopyResponse(dest http.ResponseWriter, src *http.Response) (written int64, err error)

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"`
}

Jump to

Keyboard shortcuts

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