From e4f0e4012395e9811b05f6e1d54a03ddc42a3b64 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 22 Oct 2023 09:28:33 -0300 Subject: [PATCH] redirect from favicon.ico to /static/... --- favicon.go | 5 ----- main.go | 2 +- redirect.go | 4 ++++ 3 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 favicon.go diff --git a/favicon.go b/favicon.go deleted file mode 100644 index 0ab9810..0000000 --- a/favicon.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -import "net/http" - -func renderFavicon(w http.ResponseWriter, r *http.Request) {} diff --git a/main.go b/main.go index 901d00b..2bb9b86 100644 --- a/main.go +++ b/main.go @@ -73,12 +73,12 @@ func main() { mux.HandleFunc("/npubs-archive/", renderArchive) mux.HandleFunc("/njump/image/", renderImage) mux.HandleFunc("/njump/proxy/", proxy) - mux.HandleFunc("/favicon.ico", renderFavicon) mux.HandleFunc("/robots.txt", renderRobots) mux.HandleFunc("/r/", renderRelayPage) mux.HandleFunc("/random", redirectToRandom) mux.HandleFunc("/e/", redirectFromESlash) mux.HandleFunc("/p/", redirectFromPSlash) + mux.HandleFunc("/favicon.ico", redirectToFavicon) mux.HandleFunc("/", renderEvent) log.Print("listening at http://0.0.0.0:" + s.Port) diff --git a/redirect.go b/redirect.go index a215c02..4c7fb7e 100644 --- a/redirect.go +++ b/redirect.go @@ -10,6 +10,10 @@ import ( "github.com/nbd-wtf/go-nostr/nip19" ) +func redirectToFavicon(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/static/favicon/android-chrome-192x192.png", http.StatusFound) +} + func redirectToRandom(w http.ResponseWriter, r *http.Request) { // 50% of chance of picking a pubkey if ra := rand.Intn(2); ra == 0 {