2016-03-27 21:37:21 +02:00
|
|
|
/*
|
2020-03-24 20:43:40 +01:00
|
|
|
* MinIO Cloud Storage, (C) 2016-2020 MinIO, Inc.
|
2016-03-27 21:37:21 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-08-19 01:23:42 +02:00
|
|
|
package cmd
|
2016-03-27 21:37:21 +02:00
|
|
|
|
2018-03-28 23:14:06 +02:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2018-04-22 04:23:54 +02:00
|
|
|
"github.com/gorilla/mux"
|
2019-07-03 07:34:32 +02:00
|
|
|
xhttp "github.com/minio/minio/cmd/http"
|
2018-03-28 23:14:06 +02:00
|
|
|
)
|
2016-03-27 21:37:21 +02:00
|
|
|
|
2019-12-03 00:54:26 +01:00
|
|
|
func newHTTPServerFn() *xhttp.Server {
|
|
|
|
globalObjLayerMutex.Lock()
|
|
|
|
defer globalObjLayerMutex.Unlock()
|
|
|
|
return globalHTTPServer
|
|
|
|
}
|
|
|
|
|
2019-11-09 18:27:23 +01:00
|
|
|
func newObjectLayerWithoutSafeModeFn() ObjectLayer {
|
|
|
|
globalObjLayerMutex.Lock()
|
|
|
|
defer globalObjLayerMutex.Unlock()
|
|
|
|
return globalObjectAPI
|
|
|
|
}
|
|
|
|
|
|
|
|
func newObjectLayerFn() ObjectLayer {
|
|
|
|
globalObjLayerMutex.Lock()
|
|
|
|
defer globalObjLayerMutex.Unlock()
|
|
|
|
if globalSafeMode {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return globalObjectAPI
|
|
|
|
}
|
|
|
|
|
|
|
|
func newCachedObjectLayerFn() CacheObjectLayer {
|
|
|
|
globalObjLayerMutex.Lock()
|
|
|
|
defer globalObjLayerMutex.Unlock()
|
|
|
|
|
|
|
|
if globalSafeMode {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return globalCacheObjectAPI
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:45:15 +02:00
|
|
|
// objectAPIHandler implements and provides http handlers for S3 API.
|
|
|
|
type objectAPIHandlers struct {
|
2016-07-31 23:11:14 +02:00
|
|
|
ObjectAPI func() ObjectLayer
|
2018-03-28 23:14:06 +02:00
|
|
|
CacheAPI func() CacheObjectLayer
|
2019-01-05 23:16:43 +01:00
|
|
|
// Returns true of handlers should interpret encryption.
|
|
|
|
EncryptionEnabled func() bool
|
2019-06-20 02:37:08 +02:00
|
|
|
// Returns true if handlers allow SSE-KMS encryption headers.
|
|
|
|
AllowSSEKMS func() bool
|
2016-03-27 21:37:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// registerAPIRouter - registers S3 compatible APIs.
|
2019-06-20 02:37:08 +02:00
|
|
|
func registerAPIRouter(router *mux.Router, encryptionEnabled, allowSSEKMS bool) {
|
2016-10-05 21:48:07 +02:00
|
|
|
// Initialize API.
|
|
|
|
api := objectAPIHandlers{
|
2019-11-09 18:27:23 +01:00
|
|
|
ObjectAPI: newObjectLayerFn,
|
|
|
|
CacheAPI: newCachedObjectLayerFn,
|
2019-01-05 23:16:43 +01:00
|
|
|
EncryptionEnabled: func() bool {
|
|
|
|
return encryptionEnabled
|
|
|
|
},
|
2019-06-20 02:37:08 +02:00
|
|
|
AllowSSEKMS: func() bool {
|
|
|
|
return allowSSEKMS
|
|
|
|
},
|
2016-10-05 21:48:07 +02:00
|
|
|
}
|
|
|
|
|
2016-03-27 21:37:21 +02:00
|
|
|
// API Router
|
2019-08-06 21:08:58 +02:00
|
|
|
apiRouter := router.PathPrefix(SlashSeparator).Subrouter()
|
2018-04-22 04:23:54 +02:00
|
|
|
var routers []*mux.Router
|
2019-02-23 04:18:01 +01:00
|
|
|
for _, domainName := range globalDomainNames {
|
2019-05-07 19:36:00 +02:00
|
|
|
routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName).Subrouter())
|
|
|
|
routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName+":{port:.*}").Subrouter())
|
2017-11-15 01:56:24 +01:00
|
|
|
}
|
|
|
|
routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter())
|
2016-03-27 21:37:21 +02:00
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
for _, bucket := range routers {
|
|
|
|
// Object operations
|
|
|
|
// HeadObject
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodHead).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("headobject", httpTraceAll(api.HeadObjectHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
// CopyObjectPart
|
2020-04-14 21:46:37 +02:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp(xhttp.AmzCopySource, ".*?(\\/|%2F).*?").HandlerFunc(maxClients(collectAPIStats("copyobjectpart", httpTraceAll(api.CopyObjectPartHandler)))).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")
|
2017-11-15 01:56:24 +01:00
|
|
|
// PutObjectPart
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putobjectpart", httpTraceHdrs(api.PutObjectPartHandler)))).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")
|
2019-08-19 23:02:54 +02:00
|
|
|
// ListObjectParts
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("listobjectparts", httpTraceAll(api.ListObjectPartsHandler)))).Queries("uploadId", "{uploadId:.*}")
|
2017-11-15 01:56:24 +01:00
|
|
|
// CompleteMultipartUpload
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("completemutipartupload", httpTraceAll(api.CompleteMultipartUploadHandler)))).Queries("uploadId", "{uploadId:.*}")
|
2017-11-15 01:56:24 +01:00
|
|
|
// NewMultipartUpload
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("newmultipartupload", httpTraceAll(api.NewMultipartUploadHandler)))).Queries("uploads", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// AbortMultipartUpload
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("abortmultipartupload", httpTraceAll(api.AbortMultipartUploadHandler)))).Queries("uploadId", "{uploadId:.*}")
|
2018-06-01 04:43:50 +02:00
|
|
|
// GetObjectACL - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getobjectacl", httpTraceHdrs(api.GetObjectACLHandler)))).Queries("acl", "")
|
2020-02-16 07:07:52 +01:00
|
|
|
// PutObjectACL - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putobjectacl", httpTraceHdrs(api.PutObjectACLHandler)))).Queries("acl", "")
|
2020-01-20 17:45:59 +01:00
|
|
|
// GetObjectTagging
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getobjecttagging", httpTraceHdrs(api.GetObjectTaggingHandler)))).Queries("tagging", "")
|
2020-01-20 17:45:59 +01:00
|
|
|
// PutObjectTagging
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putobjecttagging", httpTraceHdrs(api.PutObjectTaggingHandler)))).Queries("tagging", "")
|
2020-01-20 17:45:59 +01:00
|
|
|
// DeleteObjectTagging
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deleteobjecttagging", httpTraceHdrs(api.DeleteObjectTaggingHandler)))).Queries("tagging", "")
|
2018-08-15 12:30:19 +02:00
|
|
|
// SelectObjectContent
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("selectobjectcontent", httpTraceHdrs(api.SelectObjectContentHandler)))).Queries("select", "").Queries("select-type", "2")
|
2019-11-20 22:18:09 +01:00
|
|
|
// GetObjectRetention
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getobjectretention", httpTraceAll(api.GetObjectRetentionHandler)))).Queries("retention", "")
|
2020-01-17 00:41:56 +01:00
|
|
|
// GetObjectLegalHold
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getobjectlegalhold", httpTraceAll(api.GetObjectLegalHoldHandler)))).Queries("legal-hold", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// GetObject
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getobject", httpTraceHdrs(api.GetObjectHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
// CopyObject
|
2020-04-14 21:46:37 +02:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp(xhttp.AmzCopySource, ".*?(\\/|%2F).*?").HandlerFunc(maxClients(collectAPIStats("copyobject", httpTraceAll(api.CopyObjectHandler))))
|
2019-11-20 22:18:09 +01:00
|
|
|
// PutObjectRetention
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putobjectretention", httpTraceAll(api.PutObjectRetentionHandler)))).Queries("retention", "")
|
2020-01-17 00:41:56 +01:00
|
|
|
// PutObjectLegalHold
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putobjectlegalhold", httpTraceAll(api.PutObjectLegalHoldHandler)))).Queries("legal-hold", "")
|
2020-01-17 00:41:56 +01:00
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
// PutObject
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putobject", httpTraceHdrs(api.PutObjectHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
// DeleteObject
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deleteobject", httpTraceAll(api.DeleteObjectHandler))))
|
2016-03-27 21:37:21 +02:00
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
/// Bucket operations
|
|
|
|
// GetBucketLocation
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketlocation", httpTraceAll(api.GetBucketLocationHandler)))).Queries("location", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// GetBucketPolicy
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketpolicy", httpTraceAll(api.GetBucketPolicyHandler)))).Queries("policy", "")
|
2019-07-19 22:20:33 +02:00
|
|
|
// GetBucketLifecycle
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketlifecycle", httpTraceAll(api.GetBucketLifecycleHandler)))).Queries("lifecycle", "")
|
2020-02-05 10:42:34 +01:00
|
|
|
// GetBucketEncryption
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketencryption", httpTraceAll(api.GetBucketEncryptionHandler)))).Queries("encryption", "")
|
2018-05-10 06:02:26 +02:00
|
|
|
|
2019-02-09 01:18:13 +01:00
|
|
|
// Dummy Bucket Calls
|
2018-05-10 06:02:26 +02:00
|
|
|
// GetBucketACL -- this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketacl", httpTraceAll(api.GetBucketACLHandler)))).Queries("acl", "")
|
2020-02-16 07:07:52 +01:00
|
|
|
// PutBucketACL -- this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucketacl", httpTraceAll(api.PutBucketACLHandler)))).Queries("acl", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketCors - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketcors", httpTraceAll(api.GetBucketCorsHandler)))).Queries("cors", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketWebsiteHandler - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketwebsite", httpTraceAll(api.GetBucketWebsiteHandler)))).Queries("website", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketAccelerateHandler - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketaccelerate", httpTraceAll(api.GetBucketAccelerateHandler)))).Queries("accelerate", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketRequestPaymentHandler - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketrequestpayment", httpTraceAll(api.GetBucketRequestPaymentHandler)))).Queries("requestPayment", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketLoggingHandler - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketlogging", httpTraceAll(api.GetBucketLoggingHandler)))).Queries("logging", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketLifecycleHandler - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketlifecycle", httpTraceAll(api.GetBucketLifecycleHandler)))).Queries("lifecycle", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketReplicationHandler - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketreplication", httpTraceAll(api.GetBucketReplicationHandler)))).Queries("replication", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// GetBucketTaggingHandler - this is a dummy call.
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbuckettagging", httpTraceAll(api.GetBucketTaggingHandler)))).Queries("tagging", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
//DeleteBucketWebsiteHandler
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deletebucketwebsite", httpTraceAll(api.DeleteBucketWebsiteHandler)))).Queries("website", "")
|
2019-02-09 01:18:13 +01:00
|
|
|
// DeleteBucketTaggingHandler
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deletebuckettagging", httpTraceAll(api.DeleteBucketTaggingHandler)))).Queries("tagging", "")
|
2018-05-10 06:02:26 +02:00
|
|
|
|
2019-11-12 23:50:18 +01:00
|
|
|
// GetBucketObjectLockConfig
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketobjectlockconfiguration", httpTraceAll(api.GetBucketObjectLockConfigHandler)))).Queries("object-lock", "")
|
2019-11-12 23:50:18 +01:00
|
|
|
// GetBucketVersioning
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketversioning", httpTraceAll(api.GetBucketVersioningHandler)))).Queries("versioning", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// GetBucketNotification
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("getbucketnotification", httpTraceAll(api.GetBucketNotificationHandler)))).Queries("notification", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// ListenBucketNotification
|
2019-10-23 06:01:14 +02:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(collectAPIStats("listenbucketnotification", httpTraceAll(api.ListenBucketNotificationHandler))).Queries("events", "{events:.*}")
|
2017-11-15 01:56:24 +01:00
|
|
|
// ListMultipartUploads
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("listmultipartuploads", httpTraceAll(api.ListMultipartUploadsHandler)))).Queries("uploads", "")
|
2019-11-21 10:54:49 +01:00
|
|
|
// ListObjectsV2M
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("listobjectsv2M", httpTraceAll(api.ListObjectsV2MHandler)))).Queries("list-type", "2", "metadata", "true")
|
2017-11-15 01:56:24 +01:00
|
|
|
// ListObjectsV2
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("listobjectsv2", httpTraceAll(api.ListObjectsV2Handler)))).Queries("list-type", "2")
|
2019-08-19 23:02:54 +02:00
|
|
|
// ListBucketVersions
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("listbucketversions", httpTraceAll(api.ListBucketObjectVersionsHandler)))).Queries("versions", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// ListObjectsV1 (Legacy)
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("listobjectsv1", httpTraceAll(api.ListObjectsV1Handler))))
|
2019-07-19 22:20:33 +02:00
|
|
|
// PutBucketLifecycle
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucketlifecycle", httpTraceAll(api.PutBucketLifecycleHandler)))).Queries("lifecycle", "")
|
2020-02-05 10:42:34 +01:00
|
|
|
// PutBucketEncryption
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucketencryption", httpTraceAll(api.PutBucketEncryptionHandler)))).Queries("encryption", "")
|
2020-02-05 10:42:34 +01:00
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
// PutBucketPolicy
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucketpolicy", httpTraceAll(api.PutBucketPolicyHandler)))).Queries("policy", "")
|
2019-07-19 22:20:33 +02:00
|
|
|
|
2019-11-12 23:50:18 +01:00
|
|
|
// PutBucketObjectLockConfig
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucketobjectlockconfig", httpTraceAll(api.PutBucketObjectLockConfigHandler)))).Queries("object-lock", "")
|
2019-11-12 23:50:18 +01:00
|
|
|
// PutBucketVersioning
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucketversioning", httpTraceAll(api.PutBucketVersioningHandler)))).Queries("versioning", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// PutBucketNotification
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucketnotification", httpTraceAll(api.PutBucketNotificationHandler)))).Queries("notification", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// PutBucket
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPut).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("putbucket", httpTraceAll(api.PutBucketHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
// HeadBucket
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodHead).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("headbucket", httpTraceAll(api.HeadBucketHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
// PostPolicy
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPost).HeadersRegexp(xhttp.ContentType, "multipart/form-data*").HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("postpolicybucket", httpTraceHdrs(api.PostPolicyBucketHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
// DeleteMultipleObjects
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodPost).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deletemultipleobjects", httpTraceAll(api.DeleteMultipleObjectsHandler)))).Queries("delete", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// DeleteBucketPolicy
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deletebucketpolicy", httpTraceAll(api.DeleteBucketPolicyHandler)))).Queries("policy", "")
|
2019-07-19 22:20:33 +02:00
|
|
|
// DeleteBucketLifecycle
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deletebucketlifecycle", httpTraceAll(api.DeleteBucketLifecycleHandler)))).Queries("lifecycle", "")
|
2020-02-05 10:42:34 +01:00
|
|
|
// DeleteBucketEncryption
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deletebucketencryption", httpTraceAll(api.DeleteBucketEncryptionHandler)))).Queries("encryption", "")
|
2017-11-15 01:56:24 +01:00
|
|
|
// DeleteBucket
|
2020-03-24 20:43:40 +01:00
|
|
|
bucket.Methods(http.MethodDelete).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("deletebucket", httpTraceAll(api.DeleteBucketHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
}
|
2016-03-27 21:37:21 +02:00
|
|
|
|
|
|
|
/// Root operation
|
|
|
|
|
|
|
|
// ListBuckets
|
2020-03-24 20:43:40 +01:00
|
|
|
apiRouter.Methods(http.MethodGet).Path(SlashSeparator).HandlerFunc(
|
2020-04-14 21:46:37 +02:00
|
|
|
maxClients(collectAPIStats("listbuckets", httpTraceAll(api.ListBucketsHandler))))
|
2017-11-15 01:56:24 +01:00
|
|
|
|
2019-11-04 18:30:59 +01:00
|
|
|
// If none of the routes match add default error handler routes
|
|
|
|
apiRouter.NotFoundHandler = http.HandlerFunc(collectAPIStats("notfound", httpTraceAll(errorResponseHandler)))
|
|
|
|
apiRouter.MethodNotAllowedHandler = http.HandlerFunc(collectAPIStats("methodnotallowed", httpTraceAll(errorResponseHandler)))
|
|
|
|
|
2016-03-27 21:37:21 +02:00
|
|
|
}
|