From 9e26229ff04ab9c6528ac23dfd7301adacfa77b9 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 1 Sep 2022 14:29:48 -0400 Subject: [PATCH] better test endpoint ui layout (#36) --- cmd/zrok/endpoint_ui/embed.go | 2 +- cmd/zrok/endpoint_ui/index.gohtml | 5 ++++- cmd/zrok/test.go | 5 ++--- ui/static.go | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/zrok/endpoint_ui/embed.go b/cmd/zrok/endpoint_ui/embed.go index 992b5261..c6c4c76f 100644 --- a/cmd/zrok/endpoint_ui/embed.go +++ b/cmd/zrok/endpoint_ui/embed.go @@ -2,5 +2,5 @@ package endpoint_ui import "embed" -//go:embed index.html +//go:embed index.gohtml var FS embed.FS diff --git a/cmd/zrok/endpoint_ui/index.gohtml b/cmd/zrok/endpoint_ui/index.gohtml index 3b91f814..e6858000 100644 --- a/cmd/zrok/endpoint_ui/index.gohtml +++ b/cmd/zrok/endpoint_ui/index.gohtml @@ -21,12 +21,15 @@ } table { table-layout: fixed; + width: 100%; } - td { + td:last-child { width: 80%; + overflow: clip; } td:first-child { width: 20%; + overflow: auto; } #banner { background-color: #3b2693; diff --git a/cmd/zrok/test.go b/cmd/zrok/test.go index a0aa893f..17b7fafc 100644 --- a/cmd/zrok/test.go +++ b/cmd/zrok/test.go @@ -37,7 +37,7 @@ func newTestEndpointCommand() *testEndpointCommand { } command := &testEndpointCommand{cmd: cmd} var err error - if command.t, err = template.ParseFS(endpoint_ui.FS, "index.html"); err != nil { + if command.t, err = template.ParseFS(endpoint_ui.FS, "index.gohtml"); err != nil { panic(err) } cmd.Flags().StringVarP(&command.address, "address", "a", "0.0.0.0", "The address for the HTTP listener") @@ -48,14 +48,13 @@ func newTestEndpointCommand() *testEndpointCommand { func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) { http.HandleFunc("/", cmd.serveIndex) - http.HandleFunc("/index.html", cmd.serveIndex) if err := http.ListenAndServe(fmt.Sprintf("%v:%d", cmd.address, cmd.port), nil); err != nil { panic(err) } } func (cmd *testEndpointCommand) serveIndex(w http.ResponseWriter, r *http.Request) { - logrus.Infof("%v {%v} -> /index.html", r.RemoteAddr, r.Host) + logrus.Infof("%v {%v} -> /index.gohtml", r.RemoteAddr, r.Host) if err := cmd.t.Execute(w, newEndpointData(r)); err != nil { log.Error(err) } diff --git a/ui/static.go b/ui/static.go index 3466d012..3575d36d 100644 --- a/ui/static.go +++ b/ui/static.go @@ -21,7 +21,7 @@ func StaticBuilder(handler http.Handler) http.Handler { logrus.Debugf("directing '%v' to static handler", r.URL.Path) staticPath := "build" - indexPath := "index.html" + indexPath := "index.gohtml" // get the absolute path to prevent directory traversal path, err := filepath.Abs(r.URL.Path) @@ -35,7 +35,7 @@ func StaticBuilder(handler http.Handler) http.Handler { _, err = FS.Open(path) if os.IsNotExist(err) { - // file does not exist, serve index.html + // file does not exist, serve index.gohtml index, err := FS.ReadFile(filepath.Join(staticPath, indexPath)) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError)