From c8f48a8fe016991e44b554d41c83ea9a7a0b1ba9 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Tue, 30 Aug 2022 12:44:13 -0400 Subject: [PATCH] embedded ziggy; flicker-free reloads --- cmd/zrok/endpoint_ui/embed.go | 2 +- cmd/zrok/endpoint_ui/index.html | 442 +++++++++++++++++++++++++++----- cmd/zrok/endpoint_ui/ziggy.svg | 259 ------------------- cmd/zrok/test.go | 8 +- 4 files changed, 388 insertions(+), 323 deletions(-) delete mode 100755 cmd/zrok/endpoint_ui/ziggy.svg diff --git a/cmd/zrok/endpoint_ui/embed.go b/cmd/zrok/endpoint_ui/embed.go index 10b848f0..992b5261 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 ziggy.svg +//go:embed index.html var FS embed.FS diff --git a/cmd/zrok/endpoint_ui/index.html b/cmd/zrok/endpoint_ui/index.html index 2c28d0b0..11fb38fa 100644 --- a/cmd/zrok/endpoint_ui/index.html +++ b/cmd/zrok/endpoint_ui/index.html @@ -1,62 +1,388 @@ - - - - - - - - - zrok - - - -
- -
-
-

The Current Now is {{ .Now }}

-

The current 'HOST' header: {{ .Host }}

-

The remote host making the request: {{ .Remote }}

-

This host has these IP addresses: {{ .Ips }}

-
-
+ + + + + + + + + zrok + + + +
+ +
+
+

The Current Now is {{ .Now }}

+

The current 'HOST' header: {{ .Host }}

+

The remote host making the request: {{ .Remote }}

+

This host has these IP addresses: {{ .Ips }}

- +
+
+ diff --git a/cmd/zrok/endpoint_ui/ziggy.svg b/cmd/zrok/endpoint_ui/ziggy.svg deleted file mode 100755 index 73647067..00000000 --- a/cmd/zrok/endpoint_ui/ziggy.svg +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cmd/zrok/test.go b/cmd/zrok/test.go index a0529e9a..e99da69a 100644 --- a/cmd/zrok/test.go +++ b/cmd/zrok/test.go @@ -47,16 +47,14 @@ func newTestEndpointCommand() *testEndpointCommand { } func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) { - fs := http.FileServer(http.FS(endpoint_ui.FS)) - http.HandleFunc("/", cmd.handleIndex) - http.HandleFunc("/index.html", cmd.handleIndex) - http.Handle("/ziggy.svg", fs) + 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) handleIndex(w http.ResponseWriter, r *http.Request) { +func (cmd *testEndpointCommand) serveIndex(w http.ResponseWriter, r *http.Request) { logrus.Infof("%v {%v} -> /index.html", r.RemoteAddr, r.Host) ed := &endpointData{ Now: time.Now(),