DecodeRequest decodes an http request into a given structure.
(w http.ResponseWriter, r *http.Request, req interface{})
| 12 | |
| 13 | // DecodeRequest decodes an http request into a given structure. |
| 14 | func DecodeRequest(w http.ResponseWriter, r *http.Request, req interface{}) (err error) { |
| 15 | if err = json.NewDecoder(r.Body).Decode(req); err != nil { |
| 16 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 17 | } |
| 18 | return |
| 19 | } |
| 20 | |
| 21 | // EncodeResponse encodes the given structure into an http response. |
| 22 | func EncodeResponse(w http.ResponseWriter, res interface{}, err bool) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…