From 4094942a243a8b1a0f1546861bc34d2aeb015e72 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 9 Feb 2026 14:52:16 +0700 Subject: [PATCH] Bug fixes new functional --- main.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index b693939..47fb6de 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/fs" "log" "net/http" "os" @@ -309,14 +308,22 @@ func main() { } }() } - staticContent, _ := fs.Sub(staticFS, ".") - staticHandler := http.FileServer(http.FS(staticContent)) + indexHTML, _ := staticFS.ReadFile("index.html") + faviconICO, _ := staticFS.ReadFile("favicon.ico") + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - if r.URL.Path == "/" { - r = r.Clone(r.Context()) - r.URL.Path = "/index.html" + switch r.URL.Path { + case "/", "/index.html": + w.Header().Set("Content-Type", "text/html; charset=utf-8") + w.WriteHeader(http.StatusOK) + _, _ = w.Write(indexHTML) + case "/favicon.ico": + w.Header().Set("Content-Type", "image/x-icon") + w.WriteHeader(http.StatusOK) + _, _ = w.Write(faviconICO) + default: + http.NotFound(w, r) } - staticHandler.ServeHTTP(w, r) }) http.HandleFunc("/api/messages", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json")