2016-12-16 01:26:15 -05:00
|
|
|
/*
|
|
|
|
* Minio Cloud Storage, (C) 2016 Minio, Inc.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
2018-01-22 17:54:55 -05:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2018-04-21 22:23:54 -04:00
|
|
|
"github.com/gorilla/mux"
|
2018-01-22 17:54:55 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
adminAPIPathPrefix = "/minio/admin"
|
|
|
|
)
|
2016-12-16 01:26:15 -05:00
|
|
|
|
|
|
|
// adminAPIHandlers provides HTTP handlers for Minio admin API.
|
|
|
|
type adminAPIHandlers struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// registerAdminRouter - Add handler functions for each service REST API routes.
|
2018-04-21 22:23:54 -04:00
|
|
|
func registerAdminRouter(router *mux.Router) {
|
2016-12-16 01:26:15 -05:00
|
|
|
|
|
|
|
adminAPI := adminAPIHandlers{}
|
|
|
|
// Admin router
|
2018-04-21 22:23:54 -04:00
|
|
|
adminRouter := router.PathPrefix(adminAPIPathPrefix).Subrouter()
|
2018-01-22 17:54:55 -05:00
|
|
|
|
|
|
|
// Version handler
|
2018-06-07 13:41:13 -04:00
|
|
|
adminRouter.Methods(http.MethodGet).Path("/version").HandlerFunc(httpTraceAll(adminAPI.VersionHandler))
|
2018-01-22 17:54:55 -05:00
|
|
|
|
|
|
|
adminV1Router := adminRouter.PathPrefix("/v1").Subrouter()
|
2016-12-16 01:26:15 -05:00
|
|
|
|
2017-01-04 02:39:22 -05:00
|
|
|
/// Service operations
|
2016-12-16 01:26:15 -05:00
|
|
|
|
|
|
|
// Service status
|
2018-06-07 13:41:13 -04:00
|
|
|
adminV1Router.Methods(http.MethodGet).Path("/service").HandlerFunc(httpTraceAll(adminAPI.ServiceStatusHandler))
|
2017-01-14 17:48:52 -05:00
|
|
|
|
2018-01-22 17:54:55 -05:00
|
|
|
// Service restart and stop - TODO
|
2018-06-07 13:41:13 -04:00
|
|
|
adminV1Router.Methods(http.MethodPost).Path("/service").HandlerFunc(httpTraceAll(adminAPI.ServiceStopNRestartHandler))
|
2017-01-04 02:39:22 -05:00
|
|
|
|
2017-02-15 13:45:45 -05:00
|
|
|
// Info operations
|
2018-06-07 13:41:13 -04:00
|
|
|
adminV1Router.Methods(http.MethodGet).Path("/info").HandlerFunc(httpTraceAll(adminAPI.ServerInfoHandler))
|
2017-02-15 13:45:45 -05:00
|
|
|
|
2017-01-17 13:02:58 -05:00
|
|
|
/// Heal operations
|
|
|
|
|
2018-01-22 17:54:55 -05:00
|
|
|
// Heal processing endpoint.
|
2018-06-07 13:41:13 -04:00
|
|
|
adminV1Router.Methods(http.MethodPost).Path("/heal/").HandlerFunc(httpTraceAll(adminAPI.HealHandler))
|
|
|
|
adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}").HandlerFunc(httpTraceAll(adminAPI.HealHandler))
|
|
|
|
adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}/{prefix:.*}").HandlerFunc(httpTraceAll(adminAPI.HealHandler))
|
2017-02-20 15:58:50 -05:00
|
|
|
|
|
|
|
/// Config operations
|
|
|
|
|
2018-01-22 17:54:55 -05:00
|
|
|
// Update credentials
|
2018-06-07 13:41:13 -04:00
|
|
|
adminV1Router.Methods(http.MethodPut).Path("/config/credential").HandlerFunc(httpTraceAll(adminAPI.UpdateCredentialsHandler))
|
2017-02-20 15:58:50 -05:00
|
|
|
// Get config
|
2018-06-07 13:41:13 -04:00
|
|
|
adminV1Router.Methods(http.MethodGet).Path("/config").HandlerFunc(httpTraceAll(adminAPI.GetConfigHandler))
|
2018-01-22 17:54:55 -05:00
|
|
|
// Set config
|
2018-06-07 13:41:13 -04:00
|
|
|
adminV1Router.Methods(http.MethodPut).Path("/config").HandlerFunc(httpTraceAll(adminAPI.SetConfigHandler))
|
2016-12-16 01:26:15 -05:00
|
|
|
}
|