v2

package
v0.0.0-...-a0c03a0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadRequest = herodot.DefaultError{
	StatusField: http.StatusText(http.StatusBadRequest),
	ErrorField:  "The request was malformed or contained invalid parameters",
	CodeField:   http.StatusBadRequest,
}
View Source
var ErrConflict = herodot.DefaultError{
	StatusField: http.StatusText(http.StatusConflict),
	ErrorField:  "The resource could not be created due to a conflict",
	CodeField:   http.StatusConflict,
}
View Source
var ErrForbidden = herodot.DefaultError{
	StatusField: http.StatusText(http.StatusForbidden),
	ErrorField:  "The requested action was forbidden",
	CodeField:   http.StatusForbidden,
}
View Source
var ErrInternalServerError = herodot.DefaultError{
	StatusField: http.StatusText(http.StatusInternalServerError),
	ErrorField:  "An internal server error occurred, please contact the system administrator",
	CodeField:   http.StatusInternalServerError,
}
View Source
var ErrNotFound = herodot.DefaultError{
	StatusField: http.StatusText(http.StatusNotFound),
	ErrorField:  "The requested resource could not be found",
	CodeField:   http.StatusNotFound,
}
View Source
var ErrUnauthorized = herodot.DefaultError{
	StatusField: http.StatusText(http.StatusUnauthorized),
	ErrorField:  "The request could not be authorized",
	CodeField:   http.StatusUnauthorized,
}
View Source
var ErrUnsupportedMediaType = herodot.DefaultError{
	StatusField: http.StatusText(http.StatusUnsupportedMediaType),
	ErrorField:  "The request is using an unknown content type",
	CodeField:   http.StatusUnsupportedMediaType,
}

Functions

This section is empty.

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func New

func New(l *logger.Logger) *Writer

func (*Writer) Write

func (wrt *Writer) Write(w of.ResponseWriter, r of.Request, e interface{})

func (*Writer) WriteCode

func (wrt *Writer) WriteCode(w of.ResponseWriter, r of.Request, code int, e interface{})

WriteCode writes a response object to the ResponseWriter and sets a response code.

func (*Writer) WriteCreated

func (wrt *Writer) WriteCreated(w of.ResponseWriter, r of.Request, location string, e interface{})

WriteCreated writes a response object to the ResponseWriter with status code 201 and the Location header set to location.

func (*Writer) WriteError

func (wrt *Writer) WriteError(w of.ResponseWriter, r of.Request, err interface{})

WriteError writes an error to ResponseWriter and tries to extract the error's status code by asserting statusCodeCarrier. If the error does not implement statusCodeCarrier, the status code is set to 500.

func (*Writer) WriteErrorCode

func (wrt *Writer) WriteErrorCode(w of.ResponseWriter, r of.Request, code int, err interface{})

WriteErrorCode writes an error to ResponseWriter and forces an error code.

Jump to

Keyboard shortcuts

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