Fix logo loading

This commit is contained in:
Anders Pitman 2021-12-14 14:54:16 -07:00
parent 94a3316e2f
commit d13486ce2c
2 changed files with 15 additions and 11 deletions

View File

@ -1,2 +1,6 @@
#!/bin/bash
inkscape -z -w 192 -h 192 logo.svg -e webui/logo.png
# old inkscape
#inkscape -z -w 192 -h 192 logo.svg -e webui/logo.png
inkscape -w 192 -h 192 logo.svg -o logo.png

View File

@ -13,7 +13,7 @@ import (
"embed"
)
//go:embed templates
//go:embed logo.png templates
var fs embed.FS
type WebUiHandler struct {
@ -111,17 +111,17 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request
h.deleteUser(w, r, tokenData)
case "/logo.png":
//logoPngBytes, err := box.Bytes("logo.png")
//if err != nil {
// w.WriteHeader(500)
// h.alertDialog(w, r, err.Error(), homePath)
// return
//}
logoPngBytes, err := fs.ReadFile("logo.png")
if err != nil {
w.WriteHeader(500)
h.alertDialog(w, r, err.Error(), "/")
return
}
//w.Header()["Content-Type"] = []string{"image/png"}
//w.Header()["Cache-Control"] = []string{"max-age=86400"}
w.Header()["Content-Type"] = []string{"image/png"}
w.Header()["Cache-Control"] = []string{"max-age=86400"}
//w.Write(logoPngBytes)
w.Write(logoPngBytes)
case "/":
http.Redirect(w, r, "/tunnels", 303)