|
@@ -1,15 +1,16 @@
|
|
|
-package main
|
|
|
|
|
|
|
+package dashboard
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"bytes"
|
|
"bytes"
|
|
|
|
|
+ "fmt"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
"os"
|
|
"os"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
- "github.com/coreos/etcd/dashboard/resources"
|
|
|
|
|
|
|
+ "github.com/coreos/etcd/mod/dashboard/resources"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-func DashboardMemoryFileServer(w http.ResponseWriter, req *http.Request) {
|
|
|
|
|
|
|
+func memoryFileServer(w http.ResponseWriter, req *http.Request) {
|
|
|
path := req.URL.Path
|
|
path := req.URL.Path
|
|
|
if len(path) == 0 {
|
|
if len(path) == 0 {
|
|
|
path = "index.html"
|
|
path = "index.html"
|
|
@@ -29,8 +30,9 @@ func DashboardMemoryFileServer(w http.ResponseWriter, req *http.Request) {
|
|
|
// DashboardHttpHandler either uses the compiled in virtual filesystem for the
|
|
// DashboardHttpHandler either uses the compiled in virtual filesystem for the
|
|
|
// dashboard assets or if ETCD_DASHBOARD_DIR is set uses that as the source of
|
|
// dashboard assets or if ETCD_DASHBOARD_DIR is set uses that as the source of
|
|
|
// assets.
|
|
// assets.
|
|
|
-func DashboardHttpHandler(prefix string) (handler http.Handler) {
|
|
|
|
|
- handler = http.HandlerFunc(DashboardMemoryFileServer)
|
|
|
|
|
|
|
+func HttpHandler() (handler http.Handler) {
|
|
|
|
|
+ fmt.Println("hello world")
|
|
|
|
|
+ handler = http.HandlerFunc(memoryFileServer)
|
|
|
|
|
|
|
|
// Serve the dashboard from a filesystem if the magic env variable is enabled
|
|
// Serve the dashboard from a filesystem if the magic env variable is enabled
|
|
|
dashDir := os.Getenv("ETCD_DASHBOARD_DIR")
|
|
dashDir := os.Getenv("ETCD_DASHBOARD_DIR")
|
|
@@ -38,5 +40,5 @@ func DashboardHttpHandler(prefix string) (handler http.Handler) {
|
|
|
handler = http.FileServer(http.Dir(dashDir))
|
|
handler = http.FileServer(http.Dir(dashDir))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return http.StripPrefix(prefix, handler)
|
|
|
|
|
|
|
+ return handler
|
|
|
}
|
|
}
|