From: Shengjing Zhu <zhsj@debian.org>
Date: Tue, 18 Aug 2020 14:39:44 +0800
Subject: disable web ui

To reduce build-depends and avoid embedded js issue
---
 cmd/internal/http/handlers.go | 49 +++----------------------------------------
 1 file changed, 3 insertions(+), 46 deletions(-)

diff --git a/cmd/internal/http/handlers.go b/cmd/internal/http/handlers.go
index 7d4bae7..2f5e3c2 100644
--- a/cmd/internal/http/handlers.go
+++ b/cmd/internal/http/handlers.go
@@ -21,17 +21,13 @@ import (
 	"github.com/google/cadvisor/cmd/internal/api"
 	"github.com/google/cadvisor/cmd/internal/healthz"
 	httpmux "github.com/google/cadvisor/cmd/internal/http/mux"
-	"github.com/google/cadvisor/cmd/internal/pages"
-	"github.com/google/cadvisor/cmd/internal/pages/static"
 	"github.com/google/cadvisor/container"
 	"github.com/google/cadvisor/manager"
 	"github.com/google/cadvisor/metrics"
 	"github.com/google/cadvisor/validate"
 
-	auth "github.com/abbot/go-http-auth"
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
-	"k8s.io/klog/v2"
 	"k8s.io/utils/clock"
 )
 
@@ -54,40 +50,9 @@ func RegisterHandlers(mux httpmux.Mux, containerManager manager.Manager, httpAut
 		return fmt.Errorf("failed to register API handlers: %s", err)
 	}
 
-	// Redirect / to containers page.
-	mux.Handle("/", http.RedirectHandler(urlBasePrefix+pages.ContainersPage, http.StatusTemporaryRedirect))
-
-	var authenticated bool
-
-	// Setup the authenticator object
-	if httpAuthFile != "" {
-		klog.V(1).Infof("Using auth file %s", httpAuthFile)
-		secrets := auth.HtpasswdFileProvider(httpAuthFile)
-		authenticator := auth.NewBasicAuthenticator(httpAuthRealm, secrets)
-		mux.HandleFunc(static.StaticResource, authenticator.Wrap(staticHandler))
-		if err := pages.RegisterHandlersBasic(mux, containerManager, authenticator, urlBasePrefix); err != nil {
-			return fmt.Errorf("failed to register pages auth handlers: %s", err)
-		}
-		authenticated = true
-	}
-	if httpAuthFile == "" && httpDigestFile != "" {
-		klog.V(1).Infof("Using digest file %s", httpDigestFile)
-		secrets := auth.HtdigestFileProvider(httpDigestFile)
-		authenticator := auth.NewDigestAuthenticator(httpDigestRealm, secrets)
-		mux.HandleFunc(static.StaticResource, authenticator.Wrap(staticHandler))
-		if err := pages.RegisterHandlersDigest(mux, containerManager, authenticator, urlBasePrefix); err != nil {
-			return fmt.Errorf("failed to register pages digest handlers: %s", err)
-		}
-		authenticated = true
-	}
-
-	// Change handler based on authenticator initalization
-	if !authenticated {
-		mux.HandleFunc(static.StaticResource, staticHandlerNoAuth)
-		if err := pages.RegisterHandlersBasic(mux, containerManager, nil, urlBasePrefix); err != nil {
-			return fmt.Errorf("failed to register pages handlers: %s", err)
-		}
-	}
+	mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
+		fmt.Fprintf(w, "cadvisor from Debian package doesn't support Web UI")
+	})
 
 	return nil
 }
@@ -119,11 +84,3 @@ func RegisterPrometheusHandler(mux httpmux.Mux, resourceManager manager.Manager,
 		promhttp.HandlerFor(r, promhttp.HandlerOpts{ErrorHandling: promhttp.ContinueOnError}).ServeHTTP(w, req)
 	}))
 }
-
-func staticHandlerNoAuth(w http.ResponseWriter, r *http.Request) {
-	static.HandleRequest(w, r.URL)
-}
-
-func staticHandler(w http.ResponseWriter, r *auth.AuthenticatedRequest) {
-	static.HandleRequest(w, r.URL)
-}
