redirect from favicon.ico to /static/...

This commit is contained in:
fiatjaf
2023-10-22 09:28:33 -03:00
parent 62ec86cf07
commit e4f0e40123
3 changed files with 5 additions and 6 deletions

View File

@@ -1,5 +0,0 @@
package main
import "net/http"
func renderFavicon(w http.ResponseWriter, r *http.Request) {}

View File

@@ -73,12 +73,12 @@ func main() {
mux.HandleFunc("/npubs-archive/", renderArchive) mux.HandleFunc("/npubs-archive/", renderArchive)
mux.HandleFunc("/njump/image/", renderImage) mux.HandleFunc("/njump/image/", renderImage)
mux.HandleFunc("/njump/proxy/", proxy) mux.HandleFunc("/njump/proxy/", proxy)
mux.HandleFunc("/favicon.ico", renderFavicon)
mux.HandleFunc("/robots.txt", renderRobots) mux.HandleFunc("/robots.txt", renderRobots)
mux.HandleFunc("/r/", renderRelayPage) mux.HandleFunc("/r/", renderRelayPage)
mux.HandleFunc("/random", redirectToRandom) mux.HandleFunc("/random", redirectToRandom)
mux.HandleFunc("/e/", redirectFromESlash) mux.HandleFunc("/e/", redirectFromESlash)
mux.HandleFunc("/p/", redirectFromPSlash) mux.HandleFunc("/p/", redirectFromPSlash)
mux.HandleFunc("/favicon.ico", redirectToFavicon)
mux.HandleFunc("/", renderEvent) mux.HandleFunc("/", renderEvent)
log.Print("listening at http://0.0.0.0:" + s.Port) log.Print("listening at http://0.0.0.0:" + s.Port)

View File

@@ -10,6 +10,10 @@ import (
"github.com/nbd-wtf/go-nostr/nip19" "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) { func redirectToRandom(w http.ResponseWriter, r *http.Request) {
// 50% of chance of picking a pubkey // 50% of chance of picking a pubkey
if ra := rand.Intn(2); ra == 0 { if ra := rand.Intn(2); ra == 0 {