Documentation
¶
Index ¶
- type Responder
- func (r *Responder) Bytes(ctx context.Context, w http.ResponseWriter, status int, resp []byte)
- func (r *Responder) Error(ctx context.Context, w http.ResponseWriter, status int, err error)
- func (r *Responder) Errors(ctx context.Context, w http.ResponseWriter, status int, errs []error)
- func (r *Responder) JSON(ctx context.Context, w http.ResponseWriter, status int, resp interface{})
- func (r *Responder) StatusCode(w http.ResponseWriter, status int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Responder ¶
type Responder struct{}
Responder is responsible for responding to http requests, providing methods for responding in with JSON and handling errors
func (*Responder) Bytes ¶
Bytes responds to a http request with the raw bytes of whatever's passed as resp. Can be used to respond with a raw string, bytes, pre-encoded object etc
func (*Responder) Error ¶
Error responds with a single error, formatted to fit in ONS's desired error response structure (essentially an array of errors)
func (*Responder) Errors ¶
Errors responds with a slice of errors formatted to ONS's desired error response structure. Note you will have to pass a slice of []error rather than slice of []{some type that implements error}. The underlying structs can be any type that implements error but the slice itself must be defined as []error
func (*Responder) JSON ¶
JSON responds to a HTTP request, expecting the response body to be marshall-able into JSON
func (*Responder) StatusCode ¶
func (r *Responder) StatusCode(w http.ResponseWriter, status int)
StatusCode responds with a raw status code