forked from TrueCloudLab/frostfs-s3-gw
[#180] api: Add continuation-token check
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
7291b81040
commit
88aaad361a
1 changed files with 17 additions and 1 deletions
|
@ -2,9 +2,11 @@ package handler
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
|
||||
)
|
||||
|
@ -120,7 +122,11 @@ func parseListObjectsArgsV2(r *http.Request) (*layer.ListObjectsParamsV2, error)
|
|||
}
|
||||
res.ListObjectsParamsCommon = *common
|
||||
|
||||
res.ContinuationToken = queryValues.Get("continuation-token")
|
||||
res.ContinuationToken, err = parseContinuationToken(queryValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.StartAfter = queryValues.Get("start-after")
|
||||
res.FetchOwner, _ = strconv.ParseBool(queryValues.Get("fetch-owner"))
|
||||
return &res, nil
|
||||
|
@ -151,6 +157,16 @@ func parseListObjectArgs(r *http.Request) (*layer.ListObjectsParamsCommon, error
|
|||
return &res, nil
|
||||
}
|
||||
|
||||
func parseContinuationToken(queryValues url.Values) (string, error) {
|
||||
if val, ok := queryValues["continuation-token"]; ok {
|
||||
if err := object.NewID().Parse(val[0]); err != nil {
|
||||
return "", api.GetAPIError(api.ErrIncorrectContinuationToken)
|
||||
}
|
||||
return val[0], nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func fillPrefixes(src []string, encode string) []CommonPrefix {
|
||||
var dst []CommonPrefix
|
||||
for _, obj := range src {
|
||||
|
|
Loading…
Reference in a new issue