forked from TrueCloudLab/frostfs-s3-gw
[#399] Add OPTIONS method for object operations
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
parent
71bae5cd9a
commit
e25dc90c20
7 changed files with 197 additions and 8 deletions
|
@ -5,7 +5,7 @@ const (
|
|||
|
||||
// bucket operations.
|
||||
|
||||
OptionsOperation = "Options"
|
||||
OptionsBucketOperation = "OptionsBucket"
|
||||
HeadBucketOperation = "HeadBucket"
|
||||
ListMultipartUploadsOperation = "ListMultipartUploads"
|
||||
GetBucketLocationOperation = "GetBucketLocation"
|
||||
|
@ -51,6 +51,7 @@ const (
|
|||
|
||||
// object operations.
|
||||
|
||||
OptionsObjectOperation = "OptionsObject"
|
||||
HeadObjectOperation = "HeadObject"
|
||||
ListPartsOperation = "ListParts"
|
||||
GetObjectACLOperation = "GetObjectACL"
|
||||
|
|
|
@ -103,7 +103,7 @@ func stats(f http.HandlerFunc, resolveCID cidResolveFunc, appMetrics *metrics.Ap
|
|||
|
||||
func requestTypeFromAPI(api string) metrics.RequestType {
|
||||
switch api {
|
||||
case OptionsOperation, HeadObjectOperation, HeadBucketOperation:
|
||||
case OptionsBucketOperation, OptionsObjectOperation, HeadObjectOperation, HeadBucketOperation:
|
||||
return metrics.HEADRequest
|
||||
case CreateMultipartUploadOperation, UploadPartCopyOperation, UploadPartOperation, CompleteMultipartUploadOperation,
|
||||
PutObjectACLOperation, PutObjectTaggingOperation, CopyObjectOperation, PutObjectRetentionOperation, PutObjectLegalHoldOperation,
|
||||
|
|
|
@ -253,7 +253,7 @@ func determineBucketOperation(r *http.Request) string {
|
|||
query := r.URL.Query()
|
||||
switch r.Method {
|
||||
case http.MethodOptions:
|
||||
return OptionsOperation
|
||||
return OptionsBucketOperation
|
||||
case http.MethodHead:
|
||||
return HeadBucketOperation
|
||||
case http.MethodGet:
|
||||
|
@ -356,6 +356,8 @@ func determineBucketOperation(r *http.Request) string {
|
|||
func determineObjectOperation(r *http.Request) string {
|
||||
query := r.URL.Query()
|
||||
switch r.Method {
|
||||
case http.MethodOptions:
|
||||
return OptionsObjectOperation
|
||||
case http.MethodHead:
|
||||
return HeadObjectOperation
|
||||
case http.MethodGet:
|
||||
|
|
|
@ -91,9 +91,9 @@ func TestDetermineBucketOperation(t *testing.T) {
|
|||
expected string
|
||||
}{
|
||||
{
|
||||
name: "OptionsOperation",
|
||||
name: "OptionsBucketOperation",
|
||||
method: http.MethodOptions,
|
||||
expected: OptionsOperation,
|
||||
expected: OptionsBucketOperation,
|
||||
},
|
||||
{
|
||||
name: "HeadBucketOperation",
|
||||
|
@ -367,6 +367,11 @@ func TestDetermineObjectOperation(t *testing.T) {
|
|||
headerKeys []string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "OptionsObjectOperation",
|
||||
method: http.MethodOptions,
|
||||
expected: OptionsObjectOperation,
|
||||
},
|
||||
{
|
||||
name: "HeadObjectOperation",
|
||||
method: http.MethodHead,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue