allocatord: avoid putting the debug mux in the http args
Since only the debug handler needs this mux, we can just pass it to the
debug handler directly.
Change-Id: I0843c75a319e3e58ae6bd6329a08aa5025589fd0
diff --git a/services/allocator/allocatord/handlers.go b/services/allocator/allocatord/handlers.go
index b946975..016e61d 100644
--- a/services/allocator/allocatord/handlers.go
+++ b/services/allocator/allocatord/handlers.go
@@ -91,7 +91,7 @@
return nil
}
-func handleDebug(ss *serverState, rs *requestState) error {
+func handleDebug(ss *serverState, rs *requestState, debugBrowserServeMux *http.ServeMux) error {
instance := rs.r.FormValue(paramName)
if instance == "" {
return fmt.Errorf("parameter %q required for instance name", paramDashboardName)
@@ -99,6 +99,6 @@
if err := checkOwner(ss.ctx, rs.email, kubeNameFromMountName(instance)); err != nil {
return err
}
- http.StripPrefix(routeDebug, ss.args.debugBrowserServeMux).ServeHTTP(rs.w, rs.r)
+ http.StripPrefix(routeDebug, debugBrowserServeMux).ServeHTTP(rs.w, rs.r)
return nil
}
diff --git a/services/allocator/allocatord/http.go b/services/allocator/allocatord/http.go
index 6e38231..872a8ce 100644
--- a/services/allocator/allocatord/http.go
+++ b/services/allocator/allocatord/http.go
@@ -79,11 +79,10 @@
dashboardGCMMetric,
dashboardGCMProject,
monitoringKeyFile string
- secureCookies bool
- oauthCreds *oauthCredentials
- baseBlessings security.Blessings
- baseBlessingNames []string
- debugBrowserServeMux *http.ServeMux
+ secureCookies bool
+ oauthCreds *oauthCredentials
+ baseBlessings security.Blessings
+ baseBlessingNames []string
// URI prefix for static assets served from (another) content server.
staticAssetsPrefix string
// Manages locally served resources.
@@ -120,7 +119,6 @@
if err != nil {
ctx.Fatalf("Failed to setup debug browser handlers: %v", err)
}
- args.debugBrowserServeMux = debugBrowserServeMux
// mutating should be true for handlers that mutate state. For such
// handlers, any re-authentication should result in redirection to the
@@ -158,7 +156,10 @@
http.Handle(routeHome, newHandler(handleHome, false))
http.Handle(routeCreate, newHandler(handleCreate, true))
http.Handle(routeDashboard, newHandler(handleDashboard, false))
- http.Handle(routeDebug+"/", newHandler(handleDebug, false))
+ http.Handle(routeDebug+"/", newHandler(
+ func(ss *serverState, rs *requestState) error {
+ return handleDebug(ss, rs, debugBrowserServeMux)
+ }, false))
http.Handle(routeDestroy, newHandler(handleDestroy, true))
http.HandleFunc(routeOauth, func(w http.ResponseWriter, r *http.Request) {
handleOauth(ctx, args, baker, w, r)