response

package
v1.20.8 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, err error)

WriteErrorResponse writes a generic error response to w.

func WriteResponse

func WriteResponse(w http.ResponseWriter, response interface{}, responseError error)

WriteResponse serialises response as JSON and writes it to w. response must be a pointer to a struct with string fields named Status and Error. On error it writes 400 for BadRequestError and 500 for everything else.

Types

type BadRequestError

type BadRequestError struct{ Err error }

BadRequestError signals that the caller supplied invalid input. WriteResponse maps it to HTTP 400 rather than 500.

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

func (*BadRequestError) Unwrap

func (e *BadRequestError) Unwrap() error

type NotFoundError

type NotFoundError struct{ Path string }

NotFoundError signals that the requested resource or route does not exist. WriteResponse maps it to HTTP 404.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Jump to

Keyboard shortcuts

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