From 76cc65531cc58a2bba681723920c2c5f00215f54 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Sun, 22 Apr 2018 07:53:54 +0530 Subject: [PATCH] use package name correctly (#5827) --- cmd/admin-handlers_test.go | 36 ++++++++++++++--------------- cmd/admin-router.go | 6 ++--- cmd/admin-rpc-server.go | 6 ++--- cmd/api-router.go | 8 +++---- cmd/browser-rpc-router.go | 6 ++--- cmd/bucket-handlers.go | 2 +- cmd/bucket-policy-handlers.go | 2 +- cmd/crossdomain-xml-handler_test.go | 6 ++--- cmd/gateway-main.go | 4 ++-- cmd/globals.go | 4 ++-- cmd/healthcheck-router.go | 6 ++--- cmd/http/server.go | 4 ++-- cmd/lock-rpc-server.go | 10 ++++---- cmd/object-handlers.go | 2 +- cmd/peer-rpc.go | 2 +- cmd/routers.go | 30 ++++++++++++------------ cmd/rpc-server_test.go | 8 +++---- cmd/server-main.go | 4 ++-- cmd/storage-rpc-server.go | 6 ++--- cmd/test-utils_test.go | 28 +++++++++++----------- cmd/web-router.go | 6 ++--- 21 files changed, 93 insertions(+), 93 deletions(-) diff --git a/cmd/admin-handlers_test.go b/cmd/admin-handlers_test.go index c8e9f02a3..57e811fe9 100644 --- a/cmd/admin-handlers_test.go +++ b/cmd/admin-handlers_test.go @@ -31,7 +31,7 @@ import ( "testing" "time" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio/pkg/auth" "github.com/minio/minio/pkg/madmin" ) @@ -140,7 +140,7 @@ type adminXLTestBed struct { configPath string xlDirs []string objLayer ObjectLayer - mux *router.Router + router *mux.Router } // prepareAdminXLTestBed - helper function that setups a single-node @@ -182,14 +182,14 @@ func prepareAdminXLTestBed() (*adminXLTestBed, error) { } // Setup admin mgmt REST API handlers. - adminRouter := router.NewRouter() + adminRouter := mux.NewRouter() registerAdminRouter(adminRouter) return &adminXLTestBed{ configPath: rootPath, xlDirs: xlDirs, objLayer: objLayer, - mux: adminRouter, + router: adminRouter, }, nil } @@ -299,7 +299,7 @@ func TestAdminVersionHandler(t *testing.T) { } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if http.StatusOK != rec.Code { t.Errorf("Unexpected status code - got %d but expected %d", rec.Code, http.StatusOK) @@ -440,7 +440,7 @@ func testServicesCmdHandler(cmd cmdType, t *testing.T) { globalMinioAddr = "127.0.0.1:9000" initGlobalAdminPeers(mustGetNewEndpointList("http://127.0.0.1:9000/d1")) - // Setting up a go routine to simulate ServerMux's + // Setting up a go routine to simulate ServerRouter's // handleServiceSignals for stop and restart commands. if cmd == restartCmd { go testServiceSignalReceiver(cmd, t) @@ -459,7 +459,7 @@ func testServicesCmdHandler(cmd cmdType, t *testing.T) { } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if cmd == statusCmd { expectedInfo := madmin.ServiceStatus{ @@ -543,7 +543,7 @@ func TestServiceSetCreds(t *testing.T) { rec := httptest.NewRecorder() // Execute request - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) // Check if the http code response is expected if rec.Code != testCase.ExpectedStatusCode { @@ -636,7 +636,7 @@ func TestListLocksHandler(t *testing.T) { t.Fatalf("Test %d - Failed to sign list locks request - %v", i+1, err) } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if test.expectedStatus != rec.Code { t.Errorf("Test %d - Expected HTTP status code %d but received %d", i+1, test.expectedStatus, rec.Code) } @@ -703,7 +703,7 @@ func TestClearLocksHandler(t *testing.T) { t.Fatalf("Test %d - Failed to sign clear locks request - %v", i+1, err) } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if test.expectedStatus != rec.Code { t.Errorf("Test %d - Expected HTTP status code %d but received %d", i+1, test.expectedStatus, rec.Code) } @@ -795,7 +795,7 @@ func TestGetConfigHandler(t *testing.T) { } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if rec.Code != http.StatusOK { t.Errorf("Expected to succeed but failed with %d", rec.Code) } @@ -829,7 +829,7 @@ func TestSetConfigHandler(t *testing.T) { } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if rec.Code != http.StatusOK { t.Errorf("Expected to succeed but failed with %d", rec.Code) } @@ -855,7 +855,7 @@ func TestSetConfigHandler(t *testing.T) { } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) respBody := string(rec.Body.Bytes()) if rec.Code != http.StatusBadRequest || !strings.Contains(respBody, "Configuration data provided exceeds the allowed maximum of") { @@ -874,7 +874,7 @@ func TestSetConfigHandler(t *testing.T) { } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) respBody := string(rec.Body.Bytes()) if rec.Code != http.StatusBadRequest || !strings.Contains(respBody, "JSON configuration provided has objects with duplicate keys") { @@ -904,7 +904,7 @@ func TestAdminServerInfo(t *testing.T) { } rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if rec.Code != http.StatusOK { t.Errorf("Expected to succeed but failed with %d", rec.Code) } @@ -1105,7 +1105,7 @@ func collectHealResults(t *testing.T, adminTestBed *adminXLTestBed, bucket, } req := mkHealStatusReq(t, bucket, prefix, clientToken) rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if http.StatusOK != rec.Code { t.Errorf("Unexpected status code - got %d but expected %d", rec.Code, http.StatusOK) @@ -1151,7 +1151,7 @@ func TestHealStartNStatusHandler(t *testing.T) { { req := mkHealStartReq(t, bucketName, objName, healOpts) rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if http.StatusOK != rec.Code { t.Errorf("Unexpected status code - got %d but expected %d", rec.Code, http.StatusOK) @@ -1171,7 +1171,7 @@ func TestHealStartNStatusHandler(t *testing.T) { // test with an invalid client token req := mkHealStatusReq(t, bucketName, objName, hss.ClientToken+hss.ClientToken) rec := httptest.NewRecorder() - adminTestBed.mux.ServeHTTP(rec, req) + adminTestBed.router.ServeHTTP(rec, req) if rec.Code != http.StatusBadRequest { t.Errorf("Unexpected status code") } diff --git a/cmd/admin-router.go b/cmd/admin-router.go index ad5a2c32c..1357d9da1 100644 --- a/cmd/admin-router.go +++ b/cmd/admin-router.go @@ -19,7 +19,7 @@ package cmd import ( "net/http" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" ) const ( @@ -31,11 +31,11 @@ type adminAPIHandlers struct { } // registerAdminRouter - Add handler functions for each service REST API routes. -func registerAdminRouter(mux *router.Router) { +func registerAdminRouter(router *mux.Router) { adminAPI := adminAPIHandlers{} // Admin router - adminRouter := mux.NewRoute().PathPrefix(adminAPIPathPrefix).Subrouter() + adminRouter := router.PathPrefix(adminAPIPathPrefix).Subrouter() // Version handler adminRouter.Methods(http.MethodGet).Path("/version").HandlerFunc(adminAPI.VersionHandler) diff --git a/cmd/admin-rpc-server.go b/cmd/admin-rpc-server.go index 836700734..7980b6e51 100644 --- a/cmd/admin-rpc-server.go +++ b/cmd/admin-rpc-server.go @@ -25,7 +25,7 @@ import ( "path/filepath" "time" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio/cmd/logger" ) @@ -219,7 +219,7 @@ func (s *adminCmd) CommitConfig(cArgs *CommitConfigArgs, cReply *CommitConfigRep // registerAdminRPCRouter - registers RPC methods for service status, // stop and restart commands. -func registerAdminRPCRouter(mux *router.Router) error { +func registerAdminRPCRouter(router *mux.Router) error { adminRPCHandler := &adminCmd{} adminRPCServer := newRPCServer() err := adminRPCServer.RegisterName("Admin", adminRPCHandler) @@ -227,7 +227,7 @@ func registerAdminRPCRouter(mux *router.Router) error { logger.LogIf(context.Background(), err) return err } - adminRouter := mux.NewRoute().PathPrefix(minioReservedBucketPath).Subrouter() + adminRouter := router.PathPrefix(minioReservedBucketPath).Subrouter() adminRouter.Path(adminPath).Handler(adminRPCServer) return nil } diff --git a/cmd/api-router.go b/cmd/api-router.go index 808fc7211..f5c51a7f4 100644 --- a/cmd/api-router.go +++ b/cmd/api-router.go @@ -19,7 +19,7 @@ package cmd import ( "net/http" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio/cmd/logger" ) @@ -30,7 +30,7 @@ type objectAPIHandlers struct { } // registerAPIRouter - registers S3 compatible APIs. -func registerAPIRouter(mux *router.Router) { +func registerAPIRouter(router *mux.Router) { var err error var cacheConfig = globalServerConfig.GetCacheConfig() if len(cacheConfig.Drives) > 0 { @@ -46,8 +46,8 @@ func registerAPIRouter(mux *router.Router) { } // API Router - apiRouter := mux.NewRoute().PathPrefix("/").Subrouter() - var routers []*router.Router + apiRouter := router.PathPrefix("/").Subrouter() + var routers []*mux.Router if globalDomainName != "" { routers = append(routers, apiRouter.Host("{bucket:.+}."+globalDomainName).Subrouter()) } diff --git a/cmd/browser-rpc-router.go b/cmd/browser-rpc-router.go index 1a48be653..98d477309 100644 --- a/cmd/browser-rpc-router.go +++ b/cmd/browser-rpc-router.go @@ -19,7 +19,7 @@ package cmd import ( "context" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio/cmd/logger" ) @@ -37,7 +37,7 @@ type browserPeerAPIHandlers struct { } // Register RPC router -func registerBrowserPeerRPCRouter(mux *router.Router) error { +func registerBrowserPeerRPCRouter(router *mux.Router) error { bpHandlers := &browserPeerAPIHandlers{AuthRPCServer{}} bpRPCServer := newRPCServer() @@ -47,7 +47,7 @@ func registerBrowserPeerRPCRouter(mux *router.Router) error { return err } - bpRouter := mux.NewRoute().PathPrefix(minioReservedBucketPath).Subrouter() + bpRouter := router.PathPrefix(minioReservedBucketPath).Subrouter() bpRouter.Path(browserPeerPath).Handler(bpRPCServer) return nil } diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 8e3a20327..c4568367a 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -30,7 +30,7 @@ import ( "strings" "sync" - mux "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio-go/pkg/policy" "github.com/minio/minio-go/pkg/set" "github.com/minio/minio/cmd/logger" diff --git a/cmd/bucket-policy-handlers.go b/cmd/bucket-policy-handlers.go index 813fde7ee..6adcf461b 100644 --- a/cmd/bucket-policy-handlers.go +++ b/cmd/bucket-policy-handlers.go @@ -26,7 +26,7 @@ import ( "strings" humanize "github.com/dustin/go-humanize" - mux "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio-go/pkg/policy" "github.com/minio/minio/cmd/logger" "github.com/minio/minio/pkg/wildcard" diff --git a/cmd/crossdomain-xml-handler_test.go b/cmd/crossdomain-xml-handler_test.go index 2a95cd093..47f4569e6 100644 --- a/cmd/crossdomain-xml-handler_test.go +++ b/cmd/crossdomain-xml-handler_test.go @@ -21,14 +21,14 @@ import ( "net/http/httptest" "testing" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" ) // Test cross domain xml handler. func TestCrossXMLHandler(t *testing.T) { // Server initialization. - mux := router.NewRouter().SkipClean(true) - handler := setCrossDomainPolicy(mux) + router := mux.NewRouter().SkipClean(true) + handler := setCrossDomainPolicy(router) srv := httptest.NewServer(handler) resp, err := http.Get(srv.URL + crossDomainXMLEntity) diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index 136124d39..dec5c95ba 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -29,7 +29,7 @@ import ( "github.com/gorilla/mux" "github.com/minio/cli" - miniohttp "github.com/minio/minio/cmd/http" + xhttp "github.com/minio/minio/cmd/http" "github.com/minio/minio/cmd/logger" ) @@ -187,7 +187,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) { // Add API router. registerAPIRouter(router) - globalHTTPServer = miniohttp.NewServer([]string{gatewayAddr}, registerHandlers(router, globalHandlers...), globalTLSCertificate) + globalHTTPServer = xhttp.NewServer([]string{gatewayAddr}, registerHandlers(router, globalHandlers...), globalTLSCertificate) // Start server, automatically configures TLS if certs are available. go func() { diff --git a/cmd/globals.go b/cmd/globals.go index eb5f3a915..6d8a33c40 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -25,7 +25,7 @@ import ( humanize "github.com/dustin/go-humanize" "github.com/fatih/color" - miniohttp "github.com/minio/minio/cmd/http" + xhttp "github.com/minio/minio/cmd/http" "github.com/minio/minio/pkg/auth" ) @@ -129,7 +129,7 @@ var ( globalTLSCertificate *tls.Certificate - globalHTTPServer *miniohttp.Server + globalHTTPServer *xhttp.Server globalHTTPServerErrorCh = make(chan error) globalOSSignalCh = make(chan os.Signal, 1) diff --git a/cmd/healthcheck-router.go b/cmd/healthcheck-router.go index 538f925d8..e97012ec9 100644 --- a/cmd/healthcheck-router.go +++ b/cmd/healthcheck-router.go @@ -19,7 +19,7 @@ package cmd import ( "net/http" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" ) const ( @@ -30,10 +30,10 @@ const ( ) // registerHealthCheckRouter - add handler functions for liveness and readiness routes. -func registerHealthCheckRouter(mux *router.Router) { +func registerHealthCheckRouter(router *mux.Router) { // Healthcheck router - healthRouter := mux.NewRoute().PathPrefix(healthCheckPathPrefix).Subrouter() + healthRouter := router.PathPrefix(healthCheckPathPrefix).Subrouter() // Liveness handler healthRouter.Methods(http.MethodGet).Path(healthCheckLivenessPath).HandlerFunc(LivenessCheckHandler) diff --git a/cmd/http/server.go b/cmd/http/server.go index 49d1640e8..91ad0e84e 100644 --- a/cmd/http/server.go +++ b/cmd/http/server.go @@ -38,10 +38,10 @@ const ( DefaultTCPKeepAliveTimeout = 10 * time.Second // DefaultReadTimeout - default timout to read data from accepted connection. - DefaultReadTimeout = 30 * time.Second + DefaultReadTimeout = 5 * time.Minute // DefaultWriteTimeout - default timout to write data to accepted connection. - DefaultWriteTimeout = 30 * time.Second + DefaultWriteTimeout = 5 * time.Minute // DefaultMaxHeaderBytes - default maximum HTTP header size in bytes. DefaultMaxHeaderBytes = 1 * humanize.MiByte diff --git a/cmd/lock-rpc-server.go b/cmd/lock-rpc-server.go index 58fab9e5a..7cd324eeb 100644 --- a/cmd/lock-rpc-server.go +++ b/cmd/lock-rpc-server.go @@ -23,7 +23,7 @@ import ( "sync" "time" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/dsync" "github.com/minio/minio/cmd/logger" ) @@ -87,22 +87,22 @@ func startLockMaintenance(lkSrv *lockServer) { } // Register distributed NS lock handlers. -func registerDistNSLockRouter(mux *router.Router, endpoints EndpointList) error { +func registerDistNSLockRouter(router *mux.Router, endpoints EndpointList) error { // Start lock maintenance from all lock servers. startLockMaintenance(globalLockServer) // Register initialized lock servers to their respective rpc endpoints. - return registerStorageLockers(mux, globalLockServer) + return registerStorageLockers(router, globalLockServer) } // registerStorageLockers - register locker rpc handlers for net/rpc library clients -func registerStorageLockers(mux *router.Router, lkSrv *lockServer) error { +func registerStorageLockers(router *mux.Router, lkSrv *lockServer) error { lockRPCServer := newRPCServer() if err := lockRPCServer.RegisterName(lockServiceName, lkSrv); err != nil { logger.LogIf(context.Background(), err) return err } - lockRouter := mux.PathPrefix(minioReservedBucketPath).Subrouter() + lockRouter := router.PathPrefix(minioReservedBucketPath).Subrouter() lockRouter.Path(lockServicePath).Handler(lockRPCServer) return nil } diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 3cc6e63d4..4013ea1c1 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -31,7 +31,7 @@ import ( "sort" "strconv" - mux "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio/cmd/logger" "github.com/minio/minio/pkg/event" "github.com/minio/minio/pkg/handlers" diff --git a/cmd/peer-rpc.go b/cmd/peer-rpc.go index ff4046675..4be111ebc 100644 --- a/cmd/peer-rpc.go +++ b/cmd/peer-rpc.go @@ -178,7 +178,7 @@ func registerS3PeerRPCRouter(router *mux.Router) error { return err } - subrouter := router.NewRoute().PathPrefix(minioReservedBucketPath).Subrouter() + subrouter := router.PathPrefix(minioReservedBucketPath).Subrouter() subrouter.Path(s3Path).Handler(peerRPCServer) return nil } diff --git a/cmd/routers.go b/cmd/routers.go index 1438f36a1..e0fb10f39 100644 --- a/cmd/routers.go +++ b/cmd/routers.go @@ -19,7 +19,7 @@ package cmd import ( "net/http" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" ) func newObjectLayerFn() (layer ObjectLayer) { @@ -34,27 +34,27 @@ func newCacheObjectsFn() CacheObjectLayer { } // Composed function registering routers for only distributed XL setup. -func registerDistXLRouters(mux *router.Router, endpoints EndpointList) error { +func registerDistXLRouters(router *mux.Router, endpoints EndpointList) error { // Register storage rpc router only if its a distributed setup. - err := registerStorageRPCRouters(mux, endpoints) + err := registerStorageRPCRouters(router, endpoints) if err != nil { return err } // Register distributed namespace lock. - err = registerDistNSLockRouter(mux, endpoints) + err = registerDistNSLockRouter(router, endpoints) if err != nil { return err } // Register S3 peer communication router. - err = registerS3PeerRPCRouter(mux) + err = registerS3PeerRPCRouter(router) if err != nil { return err } // Register RPC router for web related calls. - return registerBrowserPeerRPCRouter(mux) + return registerBrowserPeerRPCRouter(router) } // List of some generic handlers which are applied for all incoming requests. @@ -100,38 +100,38 @@ var globalHandlers = []HandlerFunc{ func configureServerHandler(endpoints EndpointList) (http.Handler, error) { // Initialize router. `SkipClean(true)` stops gorilla/mux from // normalizing URL path minio/minio#3256 - mux := router.NewRouter().SkipClean(true) + router := mux.NewRouter().SkipClean(true) // Initialize distributed NS lock. if globalIsDistXL { - registerDistXLRouters(mux, endpoints) + registerDistXLRouters(router, endpoints) } // Add Admin RPC router - err := registerAdminRPCRouter(mux) + err := registerAdminRPCRouter(router) if err != nil { return nil, err } // Add Admin router. - registerAdminRouter(mux) + registerAdminRouter(router) // Add healthcheck router - registerHealthCheckRouter(mux) + registerHealthCheckRouter(router) // Add server metrics router - registerMetricsRouter(mux) + registerMetricsRouter(router) // Register web router when its enabled. if globalIsBrowserEnabled { - if err := registerWebRouter(mux); err != nil { + if err := registerWebRouter(router); err != nil { return nil, err } } // Add API router. - registerAPIRouter(mux) + registerAPIRouter(router) // Register rest of the handlers. - return registerHandlers(mux, globalHandlers...), nil + return registerHandlers(router, globalHandlers...), nil } diff --git a/cmd/rpc-server_test.go b/cmd/rpc-server_test.go index 9e9c62fa1..90e2fc623 100644 --- a/cmd/rpc-server_test.go +++ b/cmd/rpc-server_test.go @@ -22,7 +22,7 @@ import ( "os" "testing" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" ) type ArithArgs struct { @@ -49,10 +49,10 @@ func TestGoHTTPRPC(t *testing.T) { AuthRPCServer: AuthRPCServer{}, }) - mux := router.NewRouter().SkipClean(true) - mux.Path("/foo").Handler(newServer) + router := mux.NewRouter().SkipClean(true) + router.Path("/foo").Handler(newServer) - httpServer := httptest.NewServer(mux) + httpServer := httptest.NewServer(router) defer httpServer.Close() rootPath, err := newTestConfig("us-east-1") diff --git a/cmd/server-main.go b/cmd/server-main.go index eca7ce284..e405761d1 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -26,7 +26,7 @@ import ( "github.com/minio/cli" "github.com/minio/dsync" - miniohttp "github.com/minio/minio/cmd/http" + xhttp "github.com/minio/minio/cmd/http" "github.com/minio/minio/cmd/logger" ) @@ -246,7 +246,7 @@ func serverMain(ctx *cli.Context) { // Initialize Admin Peers inter-node communication only in distributed setup. initGlobalAdminPeers(globalEndpoints) - globalHTTPServer = miniohttp.NewServer([]string{globalMinioAddr}, handler, globalTLSCertificate) + globalHTTPServer = xhttp.NewServer([]string{globalMinioAddr}, handler, globalTLSCertificate) globalHTTPServer.ReadTimeout = globalConnReadTimeout globalHTTPServer.WriteTimeout = globalConnWriteTimeout globalHTTPServer.UpdateBytesReadFunc = globalConnStats.incInputBytes diff --git a/cmd/storage-rpc-server.go b/cmd/storage-rpc-server.go index 3a6a3cc8a..f29782c1d 100644 --- a/cmd/storage-rpc-server.go +++ b/cmd/storage-rpc-server.go @@ -22,7 +22,7 @@ import ( "path" "time" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio/cmd/logger" "github.com/minio/minio/pkg/disk" ) @@ -221,7 +221,7 @@ func newStorageRPCServer(endpoints EndpointList) (servers []*storageServer, err } // registerStorageRPCRouter - register storage rpc router. -func registerStorageRPCRouters(mux *router.Router, endpoints EndpointList) error { +func registerStorageRPCRouters(router *mux.Router, endpoints EndpointList) error { // Initialize storage rpc servers for every disk that is hosted on this node. storageRPCs, err := newStorageRPCServer(endpoints) if err != nil { @@ -238,7 +238,7 @@ func registerStorageRPCRouters(mux *router.Router, endpoints EndpointList) error return err } // Add minio storage routes. - storageRouter := mux.PathPrefix(minioReservedBucketPath).Subrouter() + storageRouter := router.PathPrefix(minioReservedBucketPath).Subrouter() storageRouter.Path(path.Join(storageRPCPath, stServer.path)).Handler(storageRPCServer) } return nil diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index e2a802c67..211d90b3f 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -52,7 +52,7 @@ import ( "time" "github.com/fatih/color" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" "github.com/minio/minio-go/pkg/policy" "github.com/minio/minio-go/pkg/s3signer" "github.com/minio/minio/cmd/logger" @@ -398,7 +398,7 @@ func StartTestServer(t TestErrHandler, instanceType string) TestServer { // The object Layer will be a temp back used for testing purpose. func initTestStorageRPCEndPoint(endpoints EndpointList) http.Handler { // Initialize router. - muxRouter := router.NewRouter().SkipClean(true) + muxRouter := mux.NewRouter().SkipClean(true) registerStorageRPCRouters(muxRouter, endpoints) return muxRouter } @@ -469,16 +469,16 @@ func StartTestPeersRPCServer(t TestErrHandler, instanceType string) TestServer { testRPCServer.Obj = objLayer globalObjLayerMutex.Unlock() - mux := router.NewRouter().SkipClean(true) + router := mux.NewRouter().SkipClean(true) // need storage layer for bucket config storage. - registerStorageRPCRouters(mux, endpoints) + registerStorageRPCRouters(router, endpoints) // need API layer to send requests, etc. - registerAPIRouter(mux) + registerAPIRouter(router) // module being tested is Peer RPCs router. - registerS3PeerRPCRouter(mux) + registerS3PeerRPCRouter(router) // Run TestServer. - testRPCServer.Server = httptest.NewServer(mux) + testRPCServer.Server = httptest.NewServer(router) // initialize remainder of serverCmdConfig testRPCServer.endpoints = endpoints @@ -2130,7 +2130,7 @@ func ExecObjectLayerStaleFilesTest(t *testing.T, objTest objTestStaleFilesType) defer removeRoots(erasureDisks) } -func registerBucketLevelFunc(bucket *router.Router, api objectAPIHandlers, apiFunctions ...string) { +func registerBucketLevelFunc(bucket *mux.Router, api objectAPIHandlers, apiFunctions ...string) { for _, apiFunction := range apiFunctions { switch apiFunction { case "PostPolicy": @@ -2204,14 +2204,14 @@ func registerBucketLevelFunc(bucket *router.Router, api objectAPIHandlers, apiFu } // registerAPIFunctions helper function to add API functions identified by name to the routers. -func registerAPIFunctions(muxRouter *router.Router, objLayer ObjectLayer, apiFunctions ...string) { +func registerAPIFunctions(muxRouter *mux.Router, objLayer ObjectLayer, apiFunctions ...string) { if len(apiFunctions) == 0 { // Register all api endpoints by default. registerAPIRouter(muxRouter) return } // API Router. - apiRouter := muxRouter.NewRoute().PathPrefix("/").Subrouter() + apiRouter := muxRouter.PathPrefix("/").Subrouter() // Bucket router. bucketRouter := apiRouter.PathPrefix("/{bucket}").Subrouter() @@ -2241,7 +2241,7 @@ func registerAPIFunctions(muxRouter *router.Router, objLayer ObjectLayer, apiFun func initTestAPIEndPoints(objLayer ObjectLayer, apiFunctions []string) http.Handler { // initialize a new mux router. // goriilla/mux is the library used to register all the routes and handle them. - muxRouter := router.NewRouter().SkipClean(true) + muxRouter := mux.NewRouter().SkipClean(true) if len(apiFunctions) > 0 { // Iterate the list of API functions requested for and register them in mux HTTP handler. registerAPIFunctions(muxRouter, objLayer, apiFunctions...) @@ -2258,7 +2258,7 @@ func initTestWebRPCEndPoint(objLayer ObjectLayer) http.Handler { globalObjLayerMutex.Unlock() // Initialize router. - muxRouter := router.NewRouter().SkipClean(true) + muxRouter := mux.NewRouter().SkipClean(true) registerWebRouter(muxRouter) return muxRouter } @@ -2266,7 +2266,7 @@ func initTestWebRPCEndPoint(objLayer ObjectLayer) http.Handler { // Initialize browser RPC endpoint. func initTestBrowserPeerRPCEndPoint() http.Handler { // Initialize router. - muxRouter := router.NewRouter().SkipClean(true) + muxRouter := mux.NewRouter().SkipClean(true) registerBrowserPeerRPCRouter(muxRouter) return muxRouter } @@ -2320,7 +2320,7 @@ func StartTestS3PeerRPCServer(t TestErrHandler) (TestServer, []string) { globalObjLayerMutex.Unlock() // Register router on a new mux - muxRouter := router.NewRouter().SkipClean(true) + muxRouter := mux.NewRouter().SkipClean(true) err = registerS3PeerRPCRouter(muxRouter) if err != nil { t.Fatalf("%s", err) diff --git a/cmd/web-router.go b/cmd/web-router.go index 7bfc7f583..82a576a84 100644 --- a/cmd/web-router.go +++ b/cmd/web-router.go @@ -23,7 +23,7 @@ import ( "github.com/elazarl/go-bindata-assetfs" "github.com/gorilla/handlers" - router "github.com/gorilla/mux" + "github.com/gorilla/mux" jsonrpc "github.com/gorilla/rpc/v2" "github.com/gorilla/rpc/v2/json2" "github.com/minio/minio/browser" @@ -60,7 +60,7 @@ func assetFS() *assetfs.AssetFS { const specialAssets = ".*index_bundle.*.js$|.*loader.css$|.*logo.svg$|.*firefox.png$|.*safari.png$|.*chrome.png$|.*favicon.ico$" // registerWebRouter - registers web router for serving minio browser. -func registerWebRouter(mux *router.Router) error { +func registerWebRouter(router *mux.Router) error { // Initialize Web. web := &webAPIHandlers{ ObjectAPI: newObjectLayerFn, @@ -71,7 +71,7 @@ func registerWebRouter(mux *router.Router) error { codec := json2.NewCodec() // Minio browser router. - webBrowserRouter := mux.NewRoute().PathPrefix(minioReservedBucketPath).Subrouter() + webBrowserRouter := router.PathPrefix(minioReservedBucketPath).Subrouter() // Initialize json rpc handlers. webRPC := jsonrpc.NewServer()