mirror of
https://github.com/minio/minio.git
synced 2025-04-20 10:37:31 -04:00
fix: muxing order for rejected APIs (#12321)
This commit is contained in:
parent
c2c803dd30
commit
ecb5525c91
@ -90,7 +90,22 @@ type rejectedAPI struct {
|
|||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
var rejectedAPIs = []rejectedAPI{
|
var rejectedObjAPIs = []rejectedAPI{
|
||||||
|
{
|
||||||
|
api: "torrent",
|
||||||
|
methods: []string{http.MethodPut, http.MethodDelete, http.MethodGet},
|
||||||
|
queries: []string{"torrent", ""},
|
||||||
|
path: "/{object:.+}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
api: "acl",
|
||||||
|
methods: []string{http.MethodDelete},
|
||||||
|
queries: []string{"acl", ""},
|
||||||
|
path: "/{object:.+}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var rejectedBucketAPIs = []rejectedAPI{
|
||||||
{
|
{
|
||||||
api: "inventory",
|
api: "inventory",
|
||||||
methods: []string{http.MethodGet, http.MethodPut, http.MethodDelete},
|
methods: []string{http.MethodGet, http.MethodPut, http.MethodDelete},
|
||||||
@ -126,18 +141,6 @@ var rejectedAPIs = []rejectedAPI{
|
|||||||
methods: []string{http.MethodPut, http.MethodDelete},
|
methods: []string{http.MethodPut, http.MethodDelete},
|
||||||
queries: []string{"requestPayment", ""},
|
queries: []string{"requestPayment", ""},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
api: "torrent",
|
|
||||||
methods: []string{http.MethodPut, http.MethodDelete, http.MethodGet},
|
|
||||||
queries: []string{"torrent", ""},
|
|
||||||
path: "/{object:.+}",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
api: "acl",
|
|
||||||
methods: []string{http.MethodDelete},
|
|
||||||
queries: []string{"acl", ""},
|
|
||||||
path: "/{object:.+}",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
api: "acl",
|
api: "acl",
|
||||||
methods: []string{http.MethodDelete, http.MethodPut, http.MethodHead},
|
methods: []string{http.MethodDelete, http.MethodPut, http.MethodHead},
|
||||||
@ -165,17 +168,6 @@ var rejectedAPIs = []rejectedAPI{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func rejectUnsupportedAPIs(router *mux.Router) {
|
|
||||||
for _, r := range rejectedAPIs {
|
|
||||||
t := router.Methods(r.methods...).
|
|
||||||
HandlerFunc(collectAPIStats(r.api, httpTraceAll(notImplementedHandler))).
|
|
||||||
Queries(r.queries...)
|
|
||||||
if r.path != "" {
|
|
||||||
t.Path(r.path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// registerAPIRouter - registers S3 compatible APIs.
|
// registerAPIRouter - registers S3 compatible APIs.
|
||||||
func registerAPIRouter(router *mux.Router) {
|
func registerAPIRouter(router *mux.Router) {
|
||||||
// Initialize API.
|
// Initialize API.
|
||||||
@ -215,7 +207,14 @@ func registerAPIRouter(router *mux.Router) {
|
|||||||
routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter())
|
routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter())
|
||||||
|
|
||||||
for _, router := range routers {
|
for _, router := range routers {
|
||||||
rejectUnsupportedAPIs(router)
|
// Register all rejected object APIs
|
||||||
|
for _, r := range rejectedObjAPIs {
|
||||||
|
t := router.Methods(r.methods...).
|
||||||
|
HandlerFunc(collectAPIStats(r.api, httpTraceAll(notImplementedHandler))).
|
||||||
|
Queries(r.queries...)
|
||||||
|
t.Path(r.path)
|
||||||
|
}
|
||||||
|
|
||||||
// Object operations
|
// Object operations
|
||||||
// HeadObject
|
// HeadObject
|
||||||
router.Methods(http.MethodHead).Path("/{object:.+}").HandlerFunc(
|
router.Methods(http.MethodHead).Path("/{object:.+}").HandlerFunc(
|
||||||
@ -422,16 +421,23 @@ func registerAPIRouter(router *mux.Router) {
|
|||||||
// DeleteBucket
|
// DeleteBucket
|
||||||
router.Methods(http.MethodDelete).HandlerFunc(
|
router.Methods(http.MethodDelete).HandlerFunc(
|
||||||
collectAPIStats("deletebucket", maxClients(httpTraceAll(api.DeleteBucketHandler))))
|
collectAPIStats("deletebucket", maxClients(httpTraceAll(api.DeleteBucketHandler))))
|
||||||
|
|
||||||
// MinIO extension API for replication.
|
// MinIO extension API for replication.
|
||||||
//
|
//
|
||||||
// GetBucketReplicationMetrics
|
// GetBucketReplicationMetrics
|
||||||
router.Methods(http.MethodGet).HandlerFunc(
|
router.Methods(http.MethodGet).HandlerFunc(
|
||||||
collectAPIStats("getbucketreplicationmetrics", maxClients(httpTraceAll(api.GetBucketReplicationMetricsHandler)))).Queries("replication-metrics", "")
|
collectAPIStats("getbucketreplicationmetrics", maxClients(httpTraceAll(api.GetBucketReplicationMetricsHandler)))).Queries("replication-metrics", "")
|
||||||
|
|
||||||
|
// Register rejected bucket APIs
|
||||||
|
for _, r := range rejectedBucketAPIs {
|
||||||
|
router.Methods(r.methods...).
|
||||||
|
HandlerFunc(collectAPIStats(r.api, httpTraceAll(notImplementedHandler))).
|
||||||
|
Queries(r.queries...)
|
||||||
|
}
|
||||||
|
|
||||||
// S3 ListObjectsV1 (Legacy)
|
// S3 ListObjectsV1 (Legacy)
|
||||||
router.Methods(http.MethodGet).HandlerFunc(
|
router.Methods(http.MethodGet).HandlerFunc(
|
||||||
collectAPIStats("listobjectsv1", maxClients(httpTraceAll(api.ListObjectsV1Handler))))
|
collectAPIStats("listobjectsv1", maxClients(httpTraceAll(api.ListObjectsV1Handler))))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Root operation
|
/// Root operation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user