diff --git a/main.go b/main.go index 8731184..fd254ab 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "embed" "encoding/json" "net/http" "net/url" @@ -41,6 +42,9 @@ var ( relay = khatru.NewRelay() ) +//go:embed static/* +var static embed.FS + func main() { err := envconfig.Process("", &s) if err != nil { @@ -104,6 +108,14 @@ func main() { relay.Router().HandleFunc("/remove-from-whitelist", removeFromWhitelistHandler) relay.Router().HandleFunc("/reports", reportsViewerHandler) relay.Router().HandleFunc("/browse", joubleHandler) + relay.Router().Handle("/static/", http.FileServer(http.FS(static))) + relay.Router().HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { + if s.RelayIcon != "" { + http.Redirect(w, r, s.RelayIcon, 302) + } else { + http.Redirect(w, r, "/static/icon.png", 302) + } + }) relay.Router().HandleFunc("/", inviteTreeHandler) log.Info().Msg("running on http://0.0.0.0:" + s.Port) diff --git a/static/icon.png b/static/icon.png new file mode 100644 index 0000000..a843721 Binary files /dev/null and b/static/icon.png differ