mirror of
https://github.com/distribution/distribution.git
synced 2025-09-26 14:49:18 +00:00
registry/api: move all errors to "errcode" package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/distribution/distribution/v3/registry/api/errcode"
|
||||
v2 "github.com/distribution/distribution/v3/registry/api/v2"
|
||||
"github.com/distribution/distribution/v3/registry/storage/driver"
|
||||
"github.com/gorilla/handlers"
|
||||
)
|
||||
@@ -47,13 +46,13 @@ func (ch *catalogHandler) GetCatalog(w http.ResponseWriter, r *http.Request) {
|
||||
if n := q.Get("n"); n != "" {
|
||||
parsedMax, err := strconv.Atoi(n)
|
||||
if err != nil || parsedMax < 0 {
|
||||
ch.Errors = append(ch.Errors, v2.ErrorCodePaginationNumberInvalid.WithDetail(map[string]string{"n": n}))
|
||||
ch.Errors = append(ch.Errors, errcode.ErrorCodePaginationNumberInvalid.WithDetail(map[string]string{"n": n}))
|
||||
return
|
||||
}
|
||||
|
||||
// if a client requests more than it's allowed to receive
|
||||
if parsedMax > maximumConfiguredEntries {
|
||||
ch.Errors = append(ch.Errors, v2.ErrorCodePaginationNumberInvalid.WithDetail(map[string]int{"n": parsedMax}))
|
||||
ch.Errors = append(ch.Errors, errcode.ErrorCodePaginationNumberInvalid.WithDetail(map[string]int{"n": parsedMax}))
|
||||
return
|
||||
}
|
||||
entries = parsedMax
|
||||
|
Reference in New Issue
Block a user