mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
feat(etcd_handlers): add the dashboard URL
/dashboard serves a dashboard now
This commit is contained in:
parent
44c16dd30d
commit
5a4f096647
@ -19,6 +19,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ func NewEtcdMuxer() *http.ServeMux {
|
|||||||
etcdMux.Handle("/"+version+"/stats/", errorHandler(StatsHttpHandler))
|
etcdMux.Handle("/"+version+"/stats/", errorHandler(StatsHttpHandler))
|
||||||
etcdMux.Handle("/version", errorHandler(VersionHttpHandler))
|
etcdMux.Handle("/version", errorHandler(VersionHttpHandler))
|
||||||
etcdMux.HandleFunc("/test/", TestHttpHandler)
|
etcdMux.HandleFunc("/test/", TestHttpHandler)
|
||||||
|
etcdMux.Handle("/dashboard/", DashboardHttpHandler())
|
||||||
return etcdMux
|
return etcdMux
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +278,19 @@ func GetHttpHandler(w http.ResponseWriter, req *http.Request) error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// assets.
|
||||||
|
func DashboardHttpHandler() http.Handler {
|
||||||
|
dashDir := os.Getenv("ETCD_DASHBOARD_DIR")
|
||||||
|
|
||||||
|
if len(dashDir) == 0 {
|
||||||
|
dashDir = "./"
|
||||||
|
}
|
||||||
|
|
||||||
|
return http.StripPrefix("/dashboard/", http.FileServer(http.Dir(dashDir)))
|
||||||
|
}
|
||||||
|
|
||||||
// Watch handler
|
// Watch handler
|
||||||
func WatchHttpHandler(w http.ResponseWriter, req *http.Request) error {
|
func WatchHttpHandler(w http.ResponseWriter, req *http.Request) error {
|
||||||
key := req.URL.Path[len("/v1/watch/"):]
|
key := req.URL.Path[len("/v1/watch/"):]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user