|
|
|
@ -57,41 +57,8 @@ func registerDistXLRouters(mux *router.Router, endpoints EndpointList) error { |
|
|
|
|
return registerBrowserPeerRPCRouter(mux) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// configureServer handler returns final handler for the http server.
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
// Initialize distributed NS lock.
|
|
|
|
|
if globalIsDistXL { |
|
|
|
|
registerDistXLRouters(mux, endpoints) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add Admin RPC router
|
|
|
|
|
err := registerAdminRPCRouter(mux) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add Admin router.
|
|
|
|
|
registerAdminRouter(mux) |
|
|
|
|
|
|
|
|
|
// Add healthcheck router
|
|
|
|
|
registerHealthCheckRouter(mux) |
|
|
|
|
|
|
|
|
|
// Register web router when its enabled.
|
|
|
|
|
if globalIsBrowserEnabled { |
|
|
|
|
if err := registerWebRouter(mux); err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add API router.
|
|
|
|
|
registerAPIRouter(mux) |
|
|
|
|
|
|
|
|
|
// List of some generic handlers which are applied for all incoming requests.
|
|
|
|
|
var handlerFns = []HandlerFunc{ |
|
|
|
|
// List of some generic handlers which are applied for all incoming requests.
|
|
|
|
|
var globalHandlers = []HandlerFunc{ |
|
|
|
|
// Ratelimit the incoming requests using a token bucket algorithm
|
|
|
|
|
setRateLimitHandler, |
|
|
|
|
// Validate all the incoming paths.
|
|
|
|
@ -125,8 +92,41 @@ func configureServerHandler(endpoints EndpointList) (http.Handler, error) { |
|
|
|
|
// for internal use only.
|
|
|
|
|
filterReservedMetadata, |
|
|
|
|
// Add new handlers here.
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// configureServer handler returns final handler for the http server.
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
// Initialize distributed NS lock.
|
|
|
|
|
if globalIsDistXL { |
|
|
|
|
registerDistXLRouters(mux, endpoints) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add Admin RPC router
|
|
|
|
|
err := registerAdminRPCRouter(mux) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add Admin router.
|
|
|
|
|
registerAdminRouter(mux) |
|
|
|
|
|
|
|
|
|
// Add healthcheck router
|
|
|
|
|
registerHealthCheckRouter(mux) |
|
|
|
|
|
|
|
|
|
// Register web router when its enabled.
|
|
|
|
|
if globalIsBrowserEnabled { |
|
|
|
|
if err := registerWebRouter(mux); err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add API router.
|
|
|
|
|
registerAPIRouter(mux) |
|
|
|
|
|
|
|
|
|
// Register rest of the handlers.
|
|
|
|
|
return registerHandlers(mux, handlerFns...), nil |
|
|
|
|
return registerHandlers(mux, globalHandlers...), nil |
|
|
|
|
} |
|
|
|
|