Documentation ¶
Overview ¶
Package response implements reflection-based net/http response encoder.
Index ¶
- func EncoderMiddleware(handler http.Handler) http.Handler
- func ValidatorMiddleware(factory rest.ResponseValidatorFactory) func(http.Handler) http.Handler
- type Encoder
- func (h *Encoder) MakeOutput(w http.ResponseWriter, ht rest.HandlerTrait) interface{}
- func (h *Encoder) SetupOutput(output interface{}, ht *rest.HandlerTrait)
- func (h *Encoder) WriteErrResponse(w http.ResponseWriter, r *http.Request, statusCode int, response interface{})
- func (h *Encoder) WriteSuccessfulResponse(w http.ResponseWriter, r *http.Request, output interface{}, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncoderMiddleware ¶
EncoderMiddleware instruments qualifying http.Handler with Encoder.
func ValidatorMiddleware ¶
ValidatorMiddleware sets up response validator in suitable handlers.
Types ¶
type Encoder ¶
type Encoder struct { JSONWriter func(v interface{}) // contains filtered or unexported fields }
Encoder prepares and writes http response.
func (*Encoder) MakeOutput ¶
func (h *Encoder) MakeOutput(w http.ResponseWriter, ht rest.HandlerTrait) interface{}
MakeOutput instantiates a value for use case output port.
func (*Encoder) SetupOutput ¶
func (h *Encoder) SetupOutput(output interface{}, ht *rest.HandlerTrait)
SetupOutput configures encoder with and instance of use case output.
func (*Encoder) WriteErrResponse ¶
func (h *Encoder) WriteErrResponse(w http.ResponseWriter, r *http.Request, statusCode int, response interface{})
WriteErrResponse encodes and writes error to response.
func (*Encoder) WriteSuccessfulResponse ¶
func (h *Encoder) WriteSuccessfulResponse( w http.ResponseWriter, r *http.Request, output interface{}, ht rest.HandlerTrait, )
WriteSuccessfulResponse encodes and writes successful output of use case interactor to http response.
Click to show internal directories.
Click to hide internal directories.