| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  |  * MinIO Cloud Storage, (C) 2016-2020 MinIO, Inc. | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08: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 07:23:42 +08:00
										 |  |  | package cmd | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | import ( | 
					
						
							|  |  |  | 	"net/http" | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 	"strconv" | 
					
						
							|  |  |  | 	"time" | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-22 10:23:54 +08:00
										 |  |  | 	"github.com/gorilla/mux" | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 	"github.com/minio/minio/cmd/config" | 
					
						
							| 
									
										
										
										
											2019-07-03 13:34:32 +08:00
										 |  |  | 	xhttp "github.com/minio/minio/cmd/http" | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 	"github.com/minio/minio/cmd/logger" | 
					
						
							|  |  |  | 	"github.com/minio/minio/pkg/env" | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-03 07:54:26 +08:00
										 |  |  | func newHTTPServerFn() *xhttp.Server { | 
					
						
							|  |  |  | 	globalObjLayerMutex.Lock() | 
					
						
							|  |  |  | 	defer globalObjLayerMutex.Unlock() | 
					
						
							|  |  |  | 	return globalHTTPServer | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-10 01:27:23 +08: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-13 03:45:15 +08:00
										 |  |  | // objectAPIHandler implements and provides http handlers for S3 API.
 | 
					
						
							|  |  |  | type objectAPIHandlers struct { | 
					
						
							| 
									
										
										
										
											2016-08-01 05:11:14 +08:00
										 |  |  | 	ObjectAPI func() ObjectLayer | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 	CacheAPI  func() CacheObjectLayer | 
					
						
							| 
									
										
										
										
											2019-01-06 06:16:43 +08:00
										 |  |  | 	// Returns true of handlers should interpret encryption.
 | 
					
						
							|  |  |  | 	EncryptionEnabled func() bool | 
					
						
							| 
									
										
										
										
											2019-06-20 08:37:08 +08:00
										 |  |  | 	// Returns true if handlers allow SSE-KMS encryption headers.
 | 
					
						
							|  |  |  | 	AllowSSEKMS func() bool | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // registerAPIRouter - registers S3 compatible APIs.
 | 
					
						
							| 
									
										
										
										
											2019-06-20 08:37:08 +08:00
										 |  |  | func registerAPIRouter(router *mux.Router, encryptionEnabled, allowSSEKMS bool) { | 
					
						
							| 
									
										
										
										
											2016-10-06 03:48:07 +08:00
										 |  |  | 	// Initialize API.
 | 
					
						
							|  |  |  | 	api := objectAPIHandlers{ | 
					
						
							| 
									
										
										
										
											2019-11-10 01:27:23 +08:00
										 |  |  | 		ObjectAPI: newObjectLayerFn, | 
					
						
							|  |  |  | 		CacheAPI:  newCachedObjectLayerFn, | 
					
						
							| 
									
										
										
										
											2019-01-06 06:16:43 +08:00
										 |  |  | 		EncryptionEnabled: func() bool { | 
					
						
							|  |  |  | 			return encryptionEnabled | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2019-06-20 08:37:08 +08:00
										 |  |  | 		AllowSSEKMS: func() bool { | 
					
						
							|  |  |  | 			return allowSSEKMS | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-10-06 03:48:07 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | 	// API Router
 | 
					
						
							| 
									
										
										
										
											2019-08-07 03:08:58 +08:00
										 |  |  | 	apiRouter := router.PathPrefix(SlashSeparator).Subrouter() | 
					
						
							| 
									
										
										
										
											2018-04-22 10:23:54 +08:00
										 |  |  | 	var routers []*mux.Router | 
					
						
							| 
									
										
										
										
											2019-02-23 11:18:01 +08:00
										 |  |  | 	for _, domainName := range globalDomainNames { | 
					
						
							| 
									
										
										
										
											2019-05-08 01:36:00 +08:00
										 |  |  | 		routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName).Subrouter()) | 
					
						
							|  |  |  | 		routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName+":{port:.*}").Subrouter()) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter()) | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 	requestsMax, _ := strconv.Atoi(env.Get(config.EnvAPIRequestsMax, "0")) | 
					
						
							|  |  |  | 	if requestsMax < 0 { | 
					
						
							|  |  |  | 		requestsMax = 0 // 0 means unlimited
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var ( | 
					
						
							|  |  |  | 		enabled              bool | 
					
						
							|  |  |  | 		requestsMaxPerServer int | 
					
						
							|  |  |  | 		requestsDeadline     time.Duration | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(globalEndpoints.Hosts()) == 0 { | 
					
						
							|  |  |  | 		requestsMaxPerServer = requestsMax | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		requestsMaxPerServer = requestsMax / len(globalEndpoints.Hosts()) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enabled = requestsMaxPerServer > 0 | 
					
						
							|  |  |  | 	if enabled { | 
					
						
							|  |  |  | 		var err error | 
					
						
							|  |  |  | 		requestsDeadline, err = time.ParseDuration(env.Get(config.EnvAPIRequestsDeadline, "10s")) | 
					
						
							|  |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			logger.Info("(%s) parsing environment value MINIO_API_REQUESTS_DEADLINE, defaulting to 10 seconds", err) | 
					
						
							|  |  |  | 			requestsDeadline = 10 * time.Second | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	requestsMaxCh := make(chan struct{}, requestsMaxPerServer) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 	for _, bucket := range routers { | 
					
						
							|  |  |  | 		// Object operations
 | 
					
						
							|  |  |  | 		// HeadObject
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodHead).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("headobject", httpTraceAll(api.HeadObjectHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// CopyObjectPart
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp(xhttp.AmzCopySource, ".*?(\\/|%2F).*?").HandlerFunc(maxClients(collectAPIStats("copyobjectpart", httpTraceAll(api.CopyObjectPartHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// PutObjectPart
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putobjectpart", httpTraceHdrs(api.PutObjectPartHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") | 
					
						
							| 
									
										
										
										
											2019-08-20 05:02:54 +08:00
										 |  |  | 		// ListObjectParts
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("listobjectparts", httpTraceAll(api.ListObjectPartsHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("uploadId", "{uploadId:.*}") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// CompleteMultipartUpload
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("completemutipartupload", httpTraceAll(api.CompleteMultipartUploadHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("uploadId", "{uploadId:.*}") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// NewMultipartUpload
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("newmultipartupload", httpTraceAll(api.NewMultipartUploadHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("uploads", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// AbortMultipartUpload
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("abortmultipartupload", httpTraceAll(api.AbortMultipartUploadHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("uploadId", "{uploadId:.*}") | 
					
						
							| 
									
										
										
										
											2018-06-01 10:43:50 +08:00
										 |  |  | 		// GetObjectACL - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getobjectacl", httpTraceHdrs(api.GetObjectACLHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("acl", "") | 
					
						
							| 
									
										
										
										
											2020-02-16 14:07:52 +08:00
										 |  |  | 		// PutObjectACL - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putobjectacl", httpTraceHdrs(api.PutObjectACLHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("acl", "") | 
					
						
							| 
									
										
										
										
											2020-01-21 00:45:59 +08:00
										 |  |  | 		// GetObjectTagging
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getobjecttagging", httpTraceHdrs(api.GetObjectTaggingHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("tagging", "") | 
					
						
							| 
									
										
										
										
											2020-01-21 00:45:59 +08:00
										 |  |  | 		// PutObjectTagging
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putobjecttagging", httpTraceHdrs(api.PutObjectTaggingHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("tagging", "") | 
					
						
							| 
									
										
										
										
											2020-01-21 00:45:59 +08:00
										 |  |  | 		// DeleteObjectTagging
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deleteobjecttagging", httpTraceHdrs(api.DeleteObjectTaggingHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("tagging", "") | 
					
						
							| 
									
										
										
										
											2018-08-15 18:30:19 +08:00
										 |  |  | 		// SelectObjectContent
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("selectobjectcontent", httpTraceHdrs(api.SelectObjectContentHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("select", "").Queries("select-type", "2") | 
					
						
							| 
									
										
										
										
											2019-11-21 05:18:09 +08:00
										 |  |  | 		// GetObjectRetention
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getobjectretention", httpTraceAll(api.GetObjectRetentionHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("retention", "") | 
					
						
							| 
									
										
										
										
											2020-01-17 07:41:56 +08:00
										 |  |  | 		// GetObjectLegalHold
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getobjectlegalhold", httpTraceAll(api.GetObjectLegalHoldHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("legal-hold", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// GetObject
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getobject", httpTraceHdrs(api.GetObjectHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// CopyObject
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp(xhttp.AmzCopySource, ".*?(\\/|%2F).*?").HandlerFunc(maxClients(collectAPIStats("copyobject", httpTraceAll(api.CopyObjectHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2019-11-21 05:18:09 +08:00
										 |  |  | 		// PutObjectRetention
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putobjectretention", httpTraceAll(api.PutObjectRetentionHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("retention", "") | 
					
						
							| 
									
										
										
										
											2020-01-17 07:41:56 +08:00
										 |  |  | 		// PutObjectLegalHold
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putobjectlegalhold", httpTraceAll(api.PutObjectLegalHoldHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("legal-hold", "") | 
					
						
							| 
									
										
										
										
											2020-01-17 07:41:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// PutObject
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putobject", httpTraceHdrs(api.PutObjectHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// DeleteObject
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deleteobject", httpTraceAll(api.DeleteObjectHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		/// Bucket operations
 | 
					
						
							|  |  |  | 		// GetBucketLocation
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketlocation", httpTraceAll(api.GetBucketLocationHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("location", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// GetBucketPolicy
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketpolicy", httpTraceAll(api.GetBucketPolicyHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("policy", "") | 
					
						
							| 
									
										
										
										
											2019-07-20 04:20:33 +08:00
										 |  |  | 		// GetBucketLifecycle
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketlifecycle", httpTraceAll(api.GetBucketLifecycleHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("lifecycle", "") | 
					
						
							| 
									
										
										
										
											2020-02-05 17:42:34 +08:00
										 |  |  | 		// GetBucketEncryption
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketencryption", httpTraceAll(api.GetBucketEncryptionHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("encryption", "") | 
					
						
							| 
									
										
										
										
											2018-05-10 12:02:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// Dummy Bucket Calls
 | 
					
						
							| 
									
										
										
										
											2018-05-10 12:02:26 +08:00
										 |  |  | 		// GetBucketACL -- this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketacl", httpTraceAll(api.GetBucketACLHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("acl", "") | 
					
						
							| 
									
										
										
										
											2020-02-16 14:07:52 +08:00
										 |  |  | 		// PutBucketACL -- this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucketacl", httpTraceAll(api.PutBucketACLHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("acl", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketCors - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketcors", httpTraceAll(api.GetBucketCorsHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("cors", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketWebsiteHandler - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketwebsite", httpTraceAll(api.GetBucketWebsiteHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("website", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketAccelerateHandler - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketaccelerate", httpTraceAll(api.GetBucketAccelerateHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("accelerate", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketRequestPaymentHandler - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketrequestpayment", httpTraceAll(api.GetBucketRequestPaymentHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("requestPayment", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketLoggingHandler - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketlogging", httpTraceAll(api.GetBucketLoggingHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("logging", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketLifecycleHandler - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketlifecycle", httpTraceAll(api.GetBucketLifecycleHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("lifecycle", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketReplicationHandler - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketreplication", httpTraceAll(api.GetBucketReplicationHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("replication", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// GetBucketTaggingHandler - this is a dummy call.
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbuckettagging", httpTraceAll(api.GetBucketTaggingHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("tagging", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		//DeleteBucketWebsiteHandler
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deletebucketwebsite", httpTraceAll(api.DeleteBucketWebsiteHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("website", "") | 
					
						
							| 
									
										
										
										
											2019-02-09 08:18:13 +08:00
										 |  |  | 		// DeleteBucketTaggingHandler
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deletebuckettagging", httpTraceAll(api.DeleteBucketTaggingHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("tagging", "") | 
					
						
							| 
									
										
										
										
											2018-05-10 12:02:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 06:50:18 +08:00
										 |  |  | 		// GetBucketObjectLockConfig
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketobjectlockconfiguration", httpTraceAll(api.GetBucketObjectLockConfigHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("object-lock", "") | 
					
						
							| 
									
										
										
										
											2019-11-13 06:50:18 +08:00
										 |  |  | 		// GetBucketVersioning
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketversioning", httpTraceAll(api.GetBucketVersioningHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("versioning", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// GetBucketNotification
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("getbucketnotification", httpTraceAll(api.GetBucketNotificationHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("notification", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// ListenBucketNotification
 | 
					
						
							| 
									
										
										
										
											2019-10-23 12:01:14 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc(collectAPIStats("listenbucketnotification", httpTraceAll(api.ListenBucketNotificationHandler))).Queries("events", "{events:.*}") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// ListMultipartUploads
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("listmultipartuploads", httpTraceAll(api.ListMultipartUploadsHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("uploads", "") | 
					
						
							| 
									
										
										
										
											2019-11-21 17:54:49 +08:00
										 |  |  | 		// ListObjectsV2M
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("listobjectsv2M", httpTraceAll(api.ListObjectsV2MHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("list-type", "2", "metadata", "true") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// ListObjectsV2
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("listobjectsv2", httpTraceAll(api.ListObjectsV2Handler)), enabled, requestsMaxCh, requestsDeadline)).Queries("list-type", "2") | 
					
						
							| 
									
										
										
										
											2019-08-20 05:02:54 +08:00
										 |  |  | 		// ListBucketVersions
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("listbucketversions", httpTraceAll(api.ListBucketObjectVersionsHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("versions", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// ListObjectsV1 (Legacy)
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodGet).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("listobjectsv1", httpTraceAll(api.ListObjectsV1Handler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2019-07-20 04:20:33 +08:00
										 |  |  | 		// PutBucketLifecycle
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucketlifecycle", httpTraceAll(api.PutBucketLifecycleHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("lifecycle", "") | 
					
						
							| 
									
										
										
										
											2020-02-05 17:42:34 +08:00
										 |  |  | 		// PutBucketEncryption
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucketencryption", httpTraceAll(api.PutBucketEncryptionHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("encryption", "") | 
					
						
							| 
									
										
										
										
											2020-02-05 17:42:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// PutBucketPolicy
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucketpolicy", httpTraceAll(api.PutBucketPolicyHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("policy", "") | 
					
						
							| 
									
										
										
										
											2019-07-20 04:20:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 06:50:18 +08:00
										 |  |  | 		// PutBucketObjectLockConfig
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucketobjectlockconfig", httpTraceAll(api.PutBucketObjectLockConfigHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("object-lock", "") | 
					
						
							| 
									
										
										
										
											2019-11-13 06:50:18 +08:00
										 |  |  | 		// PutBucketVersioning
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucketversioning", httpTraceAll(api.PutBucketVersioningHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("versioning", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// PutBucketNotification
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucketnotification", httpTraceAll(api.PutBucketNotificationHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("notification", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// PutBucket
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPut).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("putbucket", httpTraceAll(api.PutBucketHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// HeadBucket
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodHead).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("headbucket", httpTraceAll(api.HeadBucketHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// PostPolicy
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPost).HeadersRegexp(xhttp.ContentType, "multipart/form-data*").HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("postpolicybucket", httpTraceHdrs(api.PostPolicyBucketHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// DeleteMultipleObjects
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodPost).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deletemultipleobjects", httpTraceAll(api.DeleteMultipleObjectsHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("delete", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// DeleteBucketPolicy
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deletebucketpolicy", httpTraceAll(api.DeleteBucketPolicyHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("policy", "") | 
					
						
							| 
									
										
										
										
											2019-07-20 04:20:33 +08:00
										 |  |  | 		// DeleteBucketLifecycle
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deletebucketlifecycle", httpTraceAll(api.DeleteBucketLifecycleHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("lifecycle", "") | 
					
						
							| 
									
										
										
										
											2020-02-05 17:42:34 +08:00
										 |  |  | 		// DeleteBucketEncryption
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deletebucketencryption", httpTraceAll(api.DeleteBucketEncryptionHandler)), enabled, requestsMaxCh, requestsDeadline)).Queries("encryption", "") | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 		// DeleteBucket
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 		bucket.Methods(http.MethodDelete).HandlerFunc( | 
					
						
							|  |  |  | 			maxClients(collectAPIStats("deletebucket", httpTraceAll(api.DeleteBucketHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-03-28 03:37:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/// Root operation
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// ListBuckets
 | 
					
						
							| 
									
										
										
										
											2020-03-25 03:43:40 +08:00
										 |  |  | 	apiRouter.Methods(http.MethodGet).Path(SlashSeparator).HandlerFunc( | 
					
						
							|  |  |  | 		maxClients(collectAPIStats("listbuckets", httpTraceAll(api.ListBucketsHandler)), enabled, requestsMaxCh, requestsDeadline)) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 01:30:59 +08: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-28 03:37:21 +08:00
										 |  |  | } |