Skip to content

Commit

Permalink
api: add bad requests to insert layer
Browse files Browse the repository at this point in the history
  • Loading branch information
jzelinskie committed Feb 24, 2016
1 parent ca2b0cc commit 6f02119
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/v1/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/coreos/clair/api/context"
"github.com/coreos/clair/database"
"github.com/coreos/clair/utils"
cerrors "github.com/coreos/clair/utils/errors"
"github.com/coreos/clair/worker"
)
Expand Down Expand Up @@ -93,7 +94,8 @@ func postLayer(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx

err = worker.Process(ctx.Store, request.Layer.Name, request.Layer.ParentName, request.Layer.Path, request.Layer.Format)
if err != nil {
if _, ok := err.(*cerrors.ErrBadRequest); ok {
_, badreq := err.(*cerrors.ErrBadRequest)
if badreq || err == utils.ErrCouldNotExtract || err == utils.ErrExtractedFileTooBig {
writeResponse(w, r, http.StatusBadRequest, LayerEnvelope{Error: &Error{err.Error()}})
return postLayerRoute, http.StatusBadRequest
}
Expand Down

0 comments on commit 6f02119

Please sign in to comment.