Move api errors to their own package and modify the typedef

This commit is contained in:
max furman 2019-12-15 23:54:25 -08:00
parent 6d6f496331
commit f9ef5070f9
13 changed files with 350 additions and 190 deletions

View file

@ -7,6 +7,7 @@ import (
"net/http"
"github.com/pkg/errors"
"github.com/smallstep/certificates/errs"
"github.com/smallstep/certificates/logging"
)
@ -68,7 +69,7 @@ func JSONStatus(w http.ResponseWriter, v interface{}, status int) {
// pointed by v.
func ReadJSON(r io.Reader, v interface{}) error {
if err := json.NewDecoder(r).Decode(v); err != nil {
return BadRequest(errors.Wrap(err, "error decoding json"))
return errs.BadRequest(errors.Wrap(err, "error decoding json"))
}
return nil
}