Skip to content

Commit 09e0e09

Browse files
committed
fix: favicon was not embeded
1 parent 799b947 commit 09e0e09

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

main.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ var migrationsFS embed.FS
4343
//go:embed index.html
4444
var indexHTML string
4545

46+
//go:embed favicon.svg
47+
var faviconSVG []byte
48+
4649
var db *sql.DB
4750

4851
func init() {
@@ -589,10 +592,21 @@ func main() {
589592
func createRouter() http.Handler {
590593
mux := http.NewServeMux()
591594

595+
// Serve favicon.svg
596+
mux.HandleFunc("/favicon.svg", func(w http.ResponseWriter, r *http.Request) {
597+
w.Header().Set("Content-Type", "image/svg+xml")
598+
w.Write(faviconSVG)
599+
})
600+
592601
// Serve embedded index.html at root
593602
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
594-
w.Header().Set("Content-Type", "text/html; charset=utf-8")
595-
fmt.Fprint(w, indexHTML)
603+
// Only serve index.html for root path or non-file paths
604+
if r.URL.Path == "/" || r.URL.Path == "" {
605+
w.Header().Set("Content-Type", "text/html; charset=utf-8")
606+
fmt.Fprint(w, indexHTML)
607+
} else {
608+
http.NotFound(w, r)
609+
}
596610
})
597611

598612
mux.HandleFunc("/api/projects", func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)