Documentation ¶
Index ¶
- Variables
- type Writer
- func (wrt *Writer) Write(w of.ResponseWriter, r of.Request, e interface{})
- func (wrt *Writer) WriteCode(w of.ResponseWriter, r of.Request, code int, e interface{})
- func (wrt *Writer) WriteCreated(w of.ResponseWriter, r of.Request, location string, e interface{})
- func (wrt *Writer) WriteError(w of.ResponseWriter, r of.Request, err interface{})
- func (wrt *Writer) WriteErrorCode(w of.ResponseWriter, r of.Request, code int, err interface{})
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
http.StatusText(http.StatusUnauthorized), ErrorField: "The request could not be authorized", CodeField: http.StatusUnauthorized, }StatusField:
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 (*Writer) WriteCode ¶
WriteCode writes a response object to the ResponseWriter and sets a response code.
func (*Writer) WriteCreated ¶
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 ¶
WriteErrorCode writes an error to ResponseWriter and forces an error code.
Click to show internal directories.
Click to hide internal directories.