mirror of https://github.com/docker/docs.git
Move the notary errors HTTP errors into the server package.
Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
parent
45c740b6b8
commit
4208945fc1
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue