favicon based on RELAY_ICON and a default.

This commit is contained in:
fiatjaf 2024-11-14 13:13:32 -03:00
parent 0a3fe7f97c
commit 448e270e6b
2 changed files with 12 additions and 0 deletions

12
main.go
View File

@ -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)

BIN
static/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB