Encode serialize response and error to the corresponding json format and write then to the output buffer. See ResponseEncoder for details.
(response interface{}, err error)
| 42 | // |
| 43 | // See ResponseEncoder for details. |
| 44 | func (s *ResponseEncoder) Encode(response interface{}, err error) { |
| 45 | if err != nil { |
| 46 | s.EncodeError(err) |
| 47 | return |
| 48 | } |
| 49 | s.EncodeResponse(response) |
| 50 | } |
| 51 | |
| 52 | // EncodeError encodes an Error. If the error is not a StatusCoder, the http.StatusInternalServerError will be used. |
| 53 | func (s *ResponseEncoder) EncodeError(err error) { |