Write writes a json encoded Response to the ResponseWriter. It uses the status code associated with the error. Write may be used as an ErrorWriter in the httpjson package.
(ctx context.Context, w http.ResponseWriter, err error)
| 71 | // |
| 72 | // Write may be used as an ErrorWriter in the httpjson package. |
| 73 | func (f Formatter) Write(ctx context.Context, w http.ResponseWriter, err error) { |
| 74 | f.Log(ctx, err) |
| 75 | resp := f.Format(err) |
| 76 | httpjson.Write(ctx, w, resp.HTTPStatus, resp) |
| 77 | } |
| 78 | |
| 79 | // Log writes a structured log entry to the chain/log logger with |
| 80 | // information about the error and the HTTP response. |