fix: resolve nlreturn, modernize, perfsprint, wsl_v5, and partial err113 lint issues

This commit is contained in:
clawbot
2026-02-20 02:59:15 -08:00
parent c65c9bbe5a
commit c1040ff69d
11 changed files with 189 additions and 44 deletions

View File

@@ -71,16 +71,20 @@ func (s *Server) SetupRoutes() {
s.log.Error("failed to get web dist filesystem", "error", err)
} else {
fileServer := http.FileServer(http.FS(distFS))
s.router.Get("/*", func(w http.ResponseWriter, r *http.Request) {
// Try to serve the file; if not found, serve index.html for SPA routing
f, err := distFS.(fs.ReadFileFS).ReadFile(r.URL.Path[1:])
if err != nil || len(f) == 0 {
indexHTML, _ := distFS.(fs.ReadFileFS).ReadFile("index.html")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
_, _ = w.Write(indexHTML)
return
}
fileServer.ServeHTTP(w, r)
})
}