diff --git a/errors/errors.go b/server/errors/errors.go similarity index 100% rename from errors/errors.go rename to server/errors/errors.go diff --git a/server/handlers/default.go b/server/handlers/default.go index cc56a13715..d4ee5183a1 100644 --- a/server/handlers/default.go +++ b/server/handlers/default.go @@ -12,7 +12,7 @@ import ( "golang.org/x/net/context" "github.com/Sirupsen/logrus" - "github.com/docker/notary/errors" + "github.com/docker/notary/server/errors" "github.com/docker/notary/server/snapshot" "github.com/docker/notary/server/storage" "github.com/docker/notary/server/timestamp" @@ -275,3 +275,9 @@ func getKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, w.Write(out) return nil } + +// NotFoundHandler is used as a generic catch all handler to return the ErrMetadataNotFound +// 404 response +func NotFoundHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { + return errors.ErrMetadataNotFound.WithDetail(nil) +} diff --git a/server/server.go b/server/server.go index cb09a48e5b..4fb863b187 100644 --- a/server/server.go +++ b/server/server.go @@ -105,7 +105,8 @@ func RootHandler(ac auth.AccessController, ctx context.Context, trust signed.Cry r.Methods("GET").Path("/_notary_server/health").HandlerFunc(health.StatusHandler) r.Methods("GET").Path("/_notary_server/metrics").Handler(prometheus.Handler()) - r.Methods("GET", "POST", "PUT", "HEAD", "DELETE").Path("/{other:.*}").Handler(hand(utils.NotFoundHandler)) + r.Methods("GET", "POST", "PUT", "HEAD", "DELETE").Path("/{other:.*}").Handler( + hand(handlers.NotFoundHandler)) return r } diff --git a/utils/http.go b/utils/http.go index 6efd0b6f04..5bf191fd46 100644 --- a/utils/http.go +++ b/utils/http.go @@ -8,7 +8,6 @@ import ( "github.com/docker/distribution/registry/api/errcode" "github.com/docker/distribution/registry/api/v2" "github.com/docker/distribution/registry/auth" - "github.com/docker/notary/errors" "github.com/docker/notary/tuf/signed" "github.com/gorilla/mux" "golang.org/x/net/context" @@ -95,9 +94,3 @@ func buildAccessRecords(repo string, actions ...string) []auth.Access { } return requiredAccess } - -// NotFoundHandler is used as a generic catch all handler to return the ErrMetadataNotFound -// 404 response -func NotFoundHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { - return errors.ErrMetadataNotFound.WithDetail(nil) -} diff --git a/utils/http_test.go b/utils/http_test.go index d2d1ef799e..62d991cbde 100644 --- a/utils/http_test.go +++ b/utils/http_test.go @@ -7,10 +7,9 @@ import ( "strings" "testing" + "github.com/docker/distribution/registry/api/errcode" "github.com/docker/notary/tuf/signed" "golang.org/x/net/context" - - "github.com/docker/notary/errors" ) func MockContextHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { @@ -18,7 +17,7 @@ func MockContextHandler(ctx context.Context, w http.ResponseWriter, r *http.Requ } func MockBetterErrorHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { - return errors.ErrUnknown.WithDetail("Test Error") + return errcode.ErrorCodeUnknown.WithDetail("Test Error") } func TestRootHandlerFactory(t *testing.T) {