mirror of
https://github.com/minio/minio.git
synced 2025-12-01 22:02:33 -05:00
Consolidating more codebase and cleanup in server / controller
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
router "github.com/gorilla/mux"
|
||||
jsonrpc "github.com/gorilla/rpc/v2"
|
||||
"github.com/gorilla/rpc/v2/json"
|
||||
"github.com/minio/minio/pkg/donut"
|
||||
)
|
||||
|
||||
// registerAPI - register all the object API handlers to their respective paths
|
||||
@@ -55,8 +56,31 @@ func registerCustomMiddleware(mux *router.Router, mwHandlers ...MiddlewareHandle
|
||||
return f
|
||||
}
|
||||
|
||||
// APIOperation container for individual operations read by Ticket Master
|
||||
type APIOperation struct {
|
||||
ProceedCh chan struct{}
|
||||
}
|
||||
|
||||
// MinioAPI container for API and also carries OP (operation) channel
|
||||
type MinioAPI struct {
|
||||
OP chan APIOperation
|
||||
Donut donut.Interface
|
||||
}
|
||||
|
||||
// getNewAPI instantiate a new minio API
|
||||
func getNewAPI() MinioAPI {
|
||||
// ignore errors for now
|
||||
d, err := donut.New()
|
||||
fatalIf(err.Trace(), "Instantiating donut failed.", nil)
|
||||
|
||||
return MinioAPI{
|
||||
OP: make(chan APIOperation),
|
||||
Donut: d,
|
||||
}
|
||||
}
|
||||
|
||||
// getAPIHandler api handler
|
||||
func getAPIHandler(conf APIConfig) (http.Handler, MinioAPI) {
|
||||
func getAPIHandler() (http.Handler, MinioAPI) {
|
||||
var mwHandlers = []MiddlewareHandler{
|
||||
ValidContentTypeHandler,
|
||||
TimeValidityHandler,
|
||||
@@ -67,7 +91,7 @@ func getAPIHandler(conf APIConfig) (http.Handler, MinioAPI) {
|
||||
}
|
||||
|
||||
mux := router.NewRouter()
|
||||
minioAPI := NewAPI()
|
||||
minioAPI := getNewAPI()
|
||||
registerAPI(mux, minioAPI)
|
||||
apiHandler := registerCustomMiddleware(mux, mwHandlers...)
|
||||
return apiHandler, minioAPI
|
||||
|
||||
Reference in New Issue
Block a user