forked from TrueCloudLab/frostfs-s3-gw
[#257] router: Use named constants
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
473239bf36
commit
ca15acf1d3
2 changed files with 134 additions and 133 deletions
|
@ -107,27 +107,27 @@ func stats(f http.HandlerFunc, resolveCID cidResolveFunc, appMetrics *metrics.Ap
|
||||||
|
|
||||||
func requestTypeFromAPI(api string) metrics.RequestType {
|
func requestTypeFromAPI(api string) metrics.RequestType {
|
||||||
switch api {
|
switch api {
|
||||||
case "Options", "HeadObject", "HeadBucket":
|
case OptionsOperation, HeadObjectOperation, HeadBucketOperation:
|
||||||
return metrics.HEADRequest
|
return metrics.HEADRequest
|
||||||
case "CreateMultipartUpload", "UploadPartCopy", "UploadPart", "CompleteMultipartUpload",
|
case CreateMultipartUploadOperation, UploadPartCopyOperation, UploadPartOperation, CompleteMultipartUploadOperation,
|
||||||
"PutObjectACL", "PutObjectTagging", "CopyObject", "PutObjectRetention", "PutObjectLegalHold",
|
PutObjectACLOperation, PutObjectTaggingOperation, CopyObjectOperation, PutObjectRetentionOperation, PutObjectLegalHoldOperation,
|
||||||
"PutObject", "PutBucketCors", "PutBucketACL", "PutBucketLifecycle", "PutBucketEncryption",
|
PutObjectOperation, PutBucketCorsOperation, PutBucketACLOperation, PutBucketLifecycleOperation, PutBucketEncryptionOperation,
|
||||||
"PutBucketPolicy", "PutBucketObjectLockConfig", "PutBucketTagging", "PutBucketVersioning",
|
PutBucketPolicyOperation, PutBucketObjectLockConfigOperation, PutBucketTaggingOperation, PutBucketVersioningOperation,
|
||||||
"PutBucketNotification", "CreateBucket", "PostObject":
|
PutBucketNotificationOperation, CreateBucketOperation, PostObjectOperation:
|
||||||
return metrics.PUTRequest
|
return metrics.PUTRequest
|
||||||
case "ListObjectParts", "ListMultipartUploads", "ListObjectsV2M", "ListObjectsV2", "ListBucketVersions",
|
case ListPartsOperation, ListMultipartUploadsOperation, ListObjectsV2MOperation, ListObjectsV2Operation,
|
||||||
"ListObjectsV1", "ListBuckets":
|
ListObjectsV1Operation, ListBucketsOperation:
|
||||||
return metrics.LISTRequest
|
return metrics.LISTRequest
|
||||||
case "GetObjectACL", "GetObjectTagging", "SelectObjectContent", "GetObjectRetention", "getobjectlegalhold",
|
case GetObjectACLOperation, GetObjectTaggingOperation, SelectObjectContentOperation, GetObjectRetentionOperation, GetObjectLegalHoldOperation,
|
||||||
"GetObjectAttributes", "GetObject", "GetBucketLocation", "GetBucketPolicy",
|
GetObjectAttributesOperation, GetObjectOperation, GetBucketLocationOperation, GetBucketPolicyOperation,
|
||||||
"GetBucketLifecycle", "GetBucketEncryption", "GetBucketCors", "GetBucketACL",
|
GetBucketLifecycleOperation, GetBucketEncryptionOperation, GetBucketCorsOperation, GetBucketACLOperation,
|
||||||
"GetBucketWebsite", "GetBucketAccelerate", "GetBucketRequestPayment", "GetBucketLogging",
|
GetBucketWebsiteOperation, GetBucketAccelerateOperation, GetBucketRequestPaymentOperation, GetBucketLoggingOperation,
|
||||||
"GetBucketReplication", "GetBucketTagging", "GetBucketObjectLockConfig",
|
GetBucketReplicationOperation, GetBucketTaggingOperation, GetBucketObjectLockConfigOperation,
|
||||||
"GetBucketVersioning", "GetBucketNotification", "ListenBucketNotification":
|
GetBucketVersioningOperation, GetBucketNotificationOperation, ListenBucketNotificationOperation:
|
||||||
return metrics.GETRequest
|
return metrics.GETRequest
|
||||||
case "AbortMultipartUpload", "DeleteObjectTagging", "DeleteObject", "DeleteBucketCors",
|
case AbortMultipartUploadOperation, DeleteObjectTaggingOperation, DeleteObjectOperation, DeleteBucketCorsOperation,
|
||||||
"DeleteBucketWebsite", "DeleteBucketTagging", "DeleteMultipleObjects", "DeleteBucketPolicy",
|
DeleteBucketWebsiteOperation, DeleteBucketTaggingOperation, DeleteMultipleObjectsOperation, DeleteBucketPolicyOperation,
|
||||||
"DeleteBucketLifecycle", "DeleteBucketEncryption", "DeleteBucket":
|
DeleteBucketLifecycleOperation, DeleteBucketEncryptionOperation, DeleteBucketOperation:
|
||||||
return metrics.DELETERequest
|
return metrics.DELETERequest
|
||||||
default:
|
default:
|
||||||
return metrics.UNKNOWNRequest
|
return metrics.UNKNOWNRequest
|
||||||
|
@ -137,7 +137,7 @@ func requestTypeFromAPI(api string) metrics.RequestType {
|
||||||
// resolveCID forms CIDResolveFunc using BucketResolveFunc.
|
// resolveCID forms CIDResolveFunc using BucketResolveFunc.
|
||||||
func resolveCID(log *zap.Logger, resolveBucket BucketResolveFunc) cidResolveFunc {
|
func resolveCID(log *zap.Logger, resolveBucket BucketResolveFunc) cidResolveFunc {
|
||||||
return func(ctx context.Context, reqInfo *ReqInfo) (cnrID string) {
|
return func(ctx context.Context, reqInfo *ReqInfo) (cnrID string) {
|
||||||
if reqInfo.BucketName == "" || reqInfo.API == "CreateBucket" || reqInfo.API == "" {
|
if reqInfo.BucketName == "" || reqInfo.API == CreateBucketOperation || reqInfo.API == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
231
api/router.go
231
api/router.go
|
@ -10,6 +10,7 @@ import (
|
||||||
s3middleware "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
s3middleware "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/internal/logs"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/metrics"
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/metrics"
|
||||||
|
"git.frostfs.info/TrueCloudLab/policy-engine/pkg/engine"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -194,139 +195,139 @@ func bucketRouter(h Handler, log *zap.Logger) chi.Router {
|
||||||
|
|
||||||
bktRouter.Options("/", h.Preflight)
|
bktRouter.Options("/", h.Preflight)
|
||||||
|
|
||||||
bktRouter.Head("/", named("HeadBucket", h.HeadBucketHandler))
|
bktRouter.Head("/", named(s3middleware.HeadBucketOperation, h.HeadBucketHandler))
|
||||||
|
|
||||||
// GET method handlers
|
// GET method handlers
|
||||||
bktRouter.Group(func(r chi.Router) {
|
bktRouter.Group(func(r chi.Router) {
|
||||||
r.Method(http.MethodGet, "/", NewHandlerFilter().
|
r.Method(http.MethodGet, "/", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("uploads").
|
Queries(s3middleware.UploadsQuery).
|
||||||
Handler(named("ListMultipartUploads", h.ListMultipartUploadsHandler))).
|
Handler(named(s3middleware.ListMultipartUploadsOperation, h.ListMultipartUploadsHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("location").
|
Queries(s3middleware.LocationQuery).
|
||||||
Handler(named("GetBucketLocation", h.GetBucketLocationHandler))).
|
Handler(named(s3middleware.GetBucketLocationOperation, h.GetBucketLocationHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("policy").
|
Queries(s3middleware.PolicyQuery).
|
||||||
Handler(named("GetBucketPolicy", h.GetBucketPolicyHandler))).
|
Handler(named(s3middleware.GetBucketPolicyOperation, h.GetBucketPolicyHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("lifecycle").
|
Queries(s3middleware.LifecycleQuery).
|
||||||
Handler(named("GetBucketLifecycle", h.GetBucketLifecycleHandler))).
|
Handler(named(s3middleware.GetBucketLifecycleOperation, h.GetBucketLifecycleHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("encryption").
|
Queries(s3middleware.EncryptionQuery).
|
||||||
Handler(named("GetBucketEncryption", h.GetBucketEncryptionHandler))).
|
Handler(named(s3middleware.GetBucketEncryptionOperation, h.GetBucketEncryptionHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("cors").
|
Queries(s3middleware.CorsQuery).
|
||||||
Handler(named("GetBucketCors", h.GetBucketCorsHandler))).
|
Handler(named(s3middleware.GetBucketCorsOperation, h.GetBucketCorsHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("acl").
|
Queries(s3middleware.ACLQuery).
|
||||||
Handler(named("GetBucketACL", h.GetBucketACLHandler))).
|
Handler(named(s3middleware.GetBucketACLOperation, h.GetBucketACLHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("website").
|
Queries(s3middleware.WebsiteQuery).
|
||||||
Handler(named("GetBucketWebsite", h.GetBucketWebsiteHandler))).
|
Handler(named(s3middleware.GetBucketWebsiteOperation, h.GetBucketWebsiteHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("accelerate").
|
Queries(s3middleware.AccelerateQuery).
|
||||||
Handler(named("GetBucketAccelerate", h.GetBucketAccelerateHandler))).
|
Handler(named(s3middleware.GetBucketAccelerateOperation, h.GetBucketAccelerateHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("requestPayment").
|
Queries(s3middleware.RequestPaymentQuery).
|
||||||
Handler(named("GetBucketRequestPayment", h.GetBucketRequestPaymentHandler))).
|
Handler(named(s3middleware.GetBucketRequestPaymentOperation, h.GetBucketRequestPaymentHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("logging").
|
Queries(s3middleware.LoggingQuery).
|
||||||
Handler(named("GetBucketLogging", h.GetBucketLoggingHandler))).
|
Handler(named(s3middleware.GetBucketLoggingOperation, h.GetBucketLoggingHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("replication").
|
Queries(s3middleware.ReplicationQuery).
|
||||||
Handler(named("GetBucketReplication", h.GetBucketReplicationHandler))).
|
Handler(named(s3middleware.GetBucketReplicationOperation, h.GetBucketReplicationHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("tagging").
|
Queries(s3middleware.TaggingQuery).
|
||||||
Handler(named("GetBucketTagging", h.GetBucketTaggingHandler))).
|
Handler(named(s3middleware.GetBucketTaggingOperation, h.GetBucketTaggingHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("object-lock").
|
Queries(s3middleware.ObjectLockQuery).
|
||||||
Handler(named("GetBucketObjectLockConfig", h.GetBucketObjectLockConfigHandler))).
|
Handler(named(s3middleware.GetBucketObjectLockConfigOperation, h.GetBucketObjectLockConfigHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("versioning").
|
Queries(s3middleware.VersioningQuery).
|
||||||
Handler(named("GetBucketVersioning", h.GetBucketVersioningHandler))).
|
Handler(named(s3middleware.GetBucketVersioningOperation, h.GetBucketVersioningHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("notification").
|
Queries(s3middleware.NotificationQuery).
|
||||||
Handler(named("GetBucketNotification", h.GetBucketNotificationHandler))).
|
Handler(named(s3middleware.GetBucketNotificationOperation, h.GetBucketNotificationHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("events").
|
Queries(s3middleware.EventsQuery).
|
||||||
Handler(named("ListenBucketNotification", h.ListenBucketNotificationHandler))).
|
Handler(named(s3middleware.ListenBucketNotificationOperation, h.ListenBucketNotificationHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
QueriesMatch("list-type", "2", "metadata", "true").
|
QueriesMatch(s3middleware.ListTypeQuery, "2", s3middleware.MetadataQuery, "true").
|
||||||
Handler(named("ListObjectsV2M", h.ListObjectsV2MHandler))).
|
Handler(named(s3middleware.ListObjectsV2MOperation, h.ListObjectsV2MHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
QueriesMatch("list-type", "2").
|
QueriesMatch(s3middleware.ListTypeQuery, "2").
|
||||||
Handler(named("ListObjectsV2", h.ListObjectsV2Handler))).
|
Handler(named(s3middleware.ListObjectsV2Operation, h.ListObjectsV2Handler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("versions").
|
Queries(s3middleware.VersionsQuery).
|
||||||
Handler(named("ListBucketObjectVersions", h.ListBucketObjectVersionsHandler))).
|
Handler(named(s3middleware.ListBucketObjectVersionsOperation, h.ListBucketObjectVersionsHandler))).
|
||||||
DefaultHandler(named("ListObjectsV1", h.ListObjectsV1Handler)))
|
DefaultHandler(named(s3middleware.ListObjectsV1Operation, h.ListObjectsV1Handler)))
|
||||||
})
|
})
|
||||||
|
|
||||||
// PUT method handlers
|
// PUT method handlers
|
||||||
bktRouter.Group(func(r chi.Router) {
|
bktRouter.Group(func(r chi.Router) {
|
||||||
r.Method(http.MethodPut, "/", NewHandlerFilter().
|
r.Method(http.MethodPut, "/", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("cors").
|
Queries(s3middleware.CorsQuery).
|
||||||
Handler(named("PutBucketCors", h.PutBucketCorsHandler))).
|
Handler(named(s3middleware.PutBucketCorsOperation, h.PutBucketCorsHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("acl").
|
Queries(s3middleware.ACLQuery).
|
||||||
Handler(named("PutBucketACL", h.PutBucketACLHandler))).
|
Handler(named(s3middleware.PutBucketACLOperation, h.PutBucketACLHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("lifecycle").
|
Queries(s3middleware.LifecycleQuery).
|
||||||
Handler(named("PutBucketLifecycle", h.PutBucketLifecycleHandler))).
|
Handler(named(s3middleware.PutBucketLifecycleOperation, h.PutBucketLifecycleHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("encryption").
|
Queries(s3middleware.EncryptionQuery).
|
||||||
Handler(named("PutBucketEncryption", h.PutBucketEncryptionHandler))).
|
Handler(named(s3middleware.PutBucketEncryptionOperation, h.PutBucketEncryptionHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("policy").
|
Queries(s3middleware.PolicyQuery).
|
||||||
Handler(named("PutBucketPolicy", h.PutBucketPolicyHandler))).
|
Handler(named(s3middleware.PutBucketPolicyOperation, h.PutBucketPolicyHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("object-lock").
|
Queries(s3middleware.ObjectLockQuery).
|
||||||
Handler(named("PutBucketObjectLockConfig", h.PutBucketObjectLockConfigHandler))).
|
Handler(named(s3middleware.PutBucketObjectLockConfigOperation, h.PutBucketObjectLockConfigHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("tagging").
|
Queries(s3middleware.TaggingQuery).
|
||||||
Handler(named("PutBucketTagging", h.PutBucketTaggingHandler))).
|
Handler(named(s3middleware.PutBucketTaggingOperation, h.PutBucketTaggingHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("versioning").
|
Queries(s3middleware.VersioningQuery).
|
||||||
Handler(named("PutBucketVersioning", h.PutBucketVersioningHandler))).
|
Handler(named(s3middleware.PutBucketVersioningOperation, h.PutBucketVersioningHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("notification").
|
Queries(s3middleware.NotificationQuery).
|
||||||
Handler(named("PutBucketNotification", h.PutBucketNotificationHandler))).
|
Handler(named(s3middleware.PutBucketNotificationOperation, h.PutBucketNotificationHandler))).
|
||||||
DefaultHandler(named("CreateBucket", h.CreateBucketHandler)))
|
DefaultHandler(named(s3middleware.CreateBucketOperation, h.CreateBucketHandler)))
|
||||||
})
|
})
|
||||||
|
|
||||||
// POST method handlers
|
// POST method handlers
|
||||||
bktRouter.Group(func(r chi.Router) {
|
bktRouter.Group(func(r chi.Router) {
|
||||||
r.Method(http.MethodPost, "/", NewHandlerFilter().
|
r.Method(http.MethodPost, "/", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("delete").
|
Queries(s3middleware.DeleteQuery).
|
||||||
Handler(named("DeleteMultipleObjects", h.DeleteMultipleObjectsHandler))).
|
Handler(named(s3middleware.DeleteMultipleObjectsOperation, h.DeleteMultipleObjectsHandler))).
|
||||||
// todo consider add filter to match header for defaultHandler: hdrContentType, "multipart/form-data*"
|
// todo consider add filter to match header for defaultHandler: hdrContentType, "multipart/form-data*"
|
||||||
DefaultHandler(named("PostObject", h.PostObject)))
|
DefaultHandler(named(s3middleware.PostObjectOperation, h.PostObject)))
|
||||||
})
|
})
|
||||||
|
|
||||||
// DELETE method handlers
|
// DELETE method handlers
|
||||||
bktRouter.Group(func(r chi.Router) {
|
bktRouter.Group(func(r chi.Router) {
|
||||||
r.Method(http.MethodDelete, "/", NewHandlerFilter().
|
r.Method(http.MethodDelete, "/", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("cors").
|
Queries(s3middleware.CorsQuery).
|
||||||
Handler(named("DeleteBucketCors", h.DeleteBucketCorsHandler))).
|
Handler(named(s3middleware.DeleteBucketCorsOperation, h.DeleteBucketCorsHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("website").
|
Queries(s3middleware.WebsiteQuery).
|
||||||
Handler(named("DeleteBucketWebsite", h.DeleteBucketWebsiteHandler))).
|
Handler(named(s3middleware.DeleteBucketWebsiteOperation, h.DeleteBucketWebsiteHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("tagging").
|
Queries(s3middleware.TaggingQuery).
|
||||||
Handler(named("DeleteBucketTagging", h.DeleteBucketTaggingHandler))).
|
Handler(named(s3middleware.DeleteBucketTaggingOperation, h.DeleteBucketTaggingHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("policy").
|
Queries(s3middleware.PolicyQuery).
|
||||||
Handler(named("PutBucketPolicy", h.PutBucketPolicyHandler))).
|
Handler(named(s3middleware.PutBucketPolicyOperation, h.PutBucketPolicyHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("lifecycle").
|
Queries(s3middleware.LifecycleQuery).
|
||||||
Handler(named("PutBucketLifecycle", h.PutBucketLifecycleHandler))).
|
Handler(named(s3middleware.PutBucketLifecycleOperation, h.PutBucketLifecycleHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("encryption").
|
Queries(s3middleware.EncryptionQuery).
|
||||||
Handler(named("DeleteBucketEncryption", h.DeleteBucketEncryptionHandler))).
|
Handler(named(s3middleware.DeleteBucketEncryptionOperation, h.DeleteBucketEncryptionHandler))).
|
||||||
DefaultHandler(named("DeleteBucket", h.DeleteBucketHandler)))
|
DefaultHandler(named(s3middleware.DeleteBucketOperation, h.DeleteBucketHandler)))
|
||||||
})
|
})
|
||||||
|
|
||||||
attachErrorHandler(bktRouter)
|
attachErrorHandler(bktRouter)
|
||||||
|
@ -338,30 +339,30 @@ func objectRouter(h Handler, l *zap.Logger) chi.Router {
|
||||||
objRouter := chi.NewRouter()
|
objRouter := chi.NewRouter()
|
||||||
objRouter.Use(s3middleware.AddObjectName(l))
|
objRouter.Use(s3middleware.AddObjectName(l))
|
||||||
|
|
||||||
objRouter.Head("/*", named("HeadObject", h.HeadObjectHandler))
|
objRouter.Head("/*", named(s3middleware.HeadObjectOperation, h.HeadObjectHandler))
|
||||||
|
|
||||||
// GET method handlers
|
// GET method handlers
|
||||||
objRouter.Group(func(r chi.Router) {
|
objRouter.Group(func(r chi.Router) {
|
||||||
r.Method(http.MethodGet, "/*", NewHandlerFilter().
|
r.Method(http.MethodGet, "/*", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("uploadId").
|
Queries(s3middleware.UploadIDQuery).
|
||||||
Handler(named("ListParts", h.ListPartsHandler))).
|
Handler(named(s3middleware.ListPartsOperation, h.ListPartsHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("acl").
|
Queries(s3middleware.ACLQuery).
|
||||||
Handler(named("GetObjectACL", h.GetObjectACLHandler))).
|
Handler(named(s3middleware.GetObjectACLOperation, h.GetObjectACLHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("tagging").
|
Queries(s3middleware.TaggingQuery).
|
||||||
Handler(named("GetObjectTagging", h.GetObjectTaggingHandler))).
|
Handler(named(s3middleware.GetObjectTaggingOperation, h.GetObjectTaggingHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("retention").
|
Queries(s3middleware.RetentionQuery).
|
||||||
Handler(named("GetObjectRetention", h.GetObjectRetentionHandler))).
|
Handler(named(s3middleware.GetObjectRetentionOperation, h.GetObjectRetentionHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("legal-hold").
|
Queries(s3middleware.LegalHoldQuery).
|
||||||
Handler(named("GetObjectLegalHold", h.GetObjectLegalHoldHandler))).
|
Handler(named(s3middleware.GetObjectLegalHoldOperation, h.GetObjectLegalHoldHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("attributes").
|
Queries(s3middleware.AttributesQuery).
|
||||||
Handler(named("GetObjectAttributes", h.GetObjectAttributesHandler))).
|
Handler(named(s3middleware.GetObjectAttributesOperation, h.GetObjectAttributesHandler))).
|
||||||
DefaultHandler(named("GetObject", h.GetObjectHandler)))
|
DefaultHandler(named(s3middleware.GetObjectOperation, h.GetObjectHandler)))
|
||||||
})
|
})
|
||||||
|
|
||||||
// PUT method handlers
|
// PUT method handlers
|
||||||
|
@ -369,51 +370,51 @@ func objectRouter(h Handler, l *zap.Logger) chi.Router {
|
||||||
r.Method(http.MethodPut, "/*", NewHandlerFilter().
|
r.Method(http.MethodPut, "/*", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Headers(AmzCopySource).
|
Headers(AmzCopySource).
|
||||||
Queries("partNumber", "uploadId").
|
Queries(s3middleware.PartNumberQuery, s3middleware.UploadIDQuery).
|
||||||
Handler(named("UploadPartCopy", h.UploadPartCopy))).
|
Handler(named(s3middleware.UploadPartCopyOperation, h.UploadPartCopy))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("partNumber", "uploadId").
|
Queries(s3middleware.PartNumberQuery, s3middleware.UploadIDQuery).
|
||||||
Handler(named("UploadPart", h.UploadPartHandler))).
|
Handler(named(s3middleware.UploadPartOperation, h.UploadPartHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("acl").
|
Queries(s3middleware.ACLQuery).
|
||||||
Handler(named("PutObjectACL", h.PutObjectACLHandler))).
|
Handler(named(s3middleware.PutObjectACLOperation, h.PutObjectACLHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("tagging").
|
Queries(s3middleware.TaggingQuery).
|
||||||
Handler(named("PutObjectTagging", h.PutObjectTaggingHandler))).
|
Handler(named(s3middleware.PutObjectTaggingOperation, h.PutObjectTaggingHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Headers(AmzCopySource).
|
Headers(AmzCopySource).
|
||||||
Handler(named("CopyObject", h.CopyObjectHandler))).
|
Handler(named(s3middleware.CopyObjectOperation, h.CopyObjectHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("retention").
|
Queries(s3middleware.RetentionQuery).
|
||||||
Handler(named("PutObjectRetention", h.PutObjectRetentionHandler))).
|
Handler(named(s3middleware.PutObjectRetentionOperation, h.PutObjectRetentionHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("legal-hold").
|
Queries(s3middleware.LegalHoldQuery).
|
||||||
Handler(named("PutObjectLegalHold", h.PutObjectLegalHoldHandler))).
|
Handler(named(s3middleware.PutObjectLegalHoldOperation, h.PutObjectLegalHoldHandler))).
|
||||||
DefaultHandler(named("PutObject", h.PutObjectHandler)))
|
DefaultHandler(named(s3middleware.PutObjectOperation, h.PutObjectHandler)))
|
||||||
})
|
})
|
||||||
|
|
||||||
// POST method handlers
|
// POST method handlers
|
||||||
objRouter.Group(func(r chi.Router) {
|
objRouter.Group(func(r chi.Router) {
|
||||||
r.Method(http.MethodPost, "/*", NewHandlerFilter().
|
r.Method(http.MethodPost, "/*", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("uploadId").
|
Queries(s3middleware.UploadIDQuery).
|
||||||
Handler(named("CompleteMultipartUpload", h.CompleteMultipartUploadHandler))).
|
Handler(named(s3middleware.CompleteMultipartUploadOperation, h.CompleteMultipartUploadHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("uploads").
|
Queries(s3middleware.UploadsQuery).
|
||||||
Handler(named("CreateMultipartUpload", h.CreateMultipartUploadHandler))).
|
Handler(named(s3middleware.CreateMultipartUploadOperation, h.CreateMultipartUploadHandler))).
|
||||||
DefaultHandler(named("SelectObjectContent", h.SelectObjectContentHandler)))
|
DefaultHandler(named(s3middleware.SelectObjectContentOperation, h.SelectObjectContentHandler)))
|
||||||
})
|
})
|
||||||
|
|
||||||
// DELETE method handlers
|
// DELETE method handlers
|
||||||
objRouter.Group(func(r chi.Router) {
|
objRouter.Group(func(r chi.Router) {
|
||||||
r.Method(http.MethodDelete, "/*", NewHandlerFilter().
|
r.Method(http.MethodDelete, "/*", NewHandlerFilter().
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("uploadId").
|
Queries(s3middleware.UploadIDQuery).
|
||||||
Handler(named("AbortMultipartUpload", h.AbortMultipartUploadHandler))).
|
Handler(named(s3middleware.AbortMultipartUploadOperation, h.AbortMultipartUploadHandler))).
|
||||||
Add(NewFilter().
|
Add(NewFilter().
|
||||||
Queries("tagging").
|
Queries(s3middleware.TaggingQuery).
|
||||||
Handler(named("DeleteObjectTagging", h.DeleteObjectTaggingHandler))).
|
Handler(named(s3middleware.DeleteObjectTaggingOperation, h.DeleteObjectTaggingHandler))).
|
||||||
DefaultHandler(named("DeleteObject", h.DeleteObjectHandler)))
|
DefaultHandler(named(s3middleware.DeleteObjectOperation, h.DeleteObjectHandler)))
|
||||||
})
|
})
|
||||||
|
|
||||||
attachErrorHandler(objRouter)
|
attachErrorHandler(objRouter)
|
||||||
|
|
Loading…
Reference in a new issue