Add favicon support - serve favicon.ico from static directory

This commit is contained in:
silberengel
2025-08-08 20:52:09 +02:00
parent 667890561a
commit 289f962420
3 changed files with 13 additions and 2 deletions

1
.gitignore vendored
View File

@@ -80,6 +80,7 @@ node_modules/**
!*.nix
!license
!readme
!*.ico
!.idea/*
!*.xml
!.name

14
main.go
View File

@@ -5,8 +5,11 @@ package main
import (
"fmt"
"github.com/pkg/profile"
"net/http"
_ "net/http/pprof"
"os"
"github.com/pkg/profile"
app2 "orly.dev/pkg/app"
"orly.dev/pkg/app/config"
"orly.dev/pkg/app/relay"
@@ -20,7 +23,6 @@ import (
"orly.dev/pkg/utils/log"
"orly.dev/pkg/utils/lol"
"orly.dev/pkg/version"
"os"
)
func main() {
@@ -76,6 +78,14 @@ func main() {
}
var opts []options.O
serveMux := servemux.NewServeMux()
// Add favicon handler
serveMux.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "image/x-icon")
w.Header().Set("Cache-Control", "public, max-age=86400") // Cache for 24 hours
http.ServeFile(w, r, "static/favicon.ico")
})
if server, err = relay.NewServer(
serverParams, serveMux, opts...,
); chk.E(err) {

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B