feat: add admin dashboard

This commit is contained in:
2026-04-29 09:44:57 -04:00
parent e319a5d092
commit baf7a497eb
11 changed files with 939 additions and 67 deletions

View File

@@ -0,0 +1,26 @@
package httpserver
import (
"net/http"
"os"
"path/filepath"
"strings"
)
func (s *Server) appFileServer() http.Handler {
files := http.FileServer(http.Dir(s.config.Web.DistDir))
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
cleanPath := filepath.Clean(strings.TrimPrefix(r.URL.Path, "/"))
if cleanPath == "." {
cleanPath = "index.html"
}
target := filepath.Join(s.config.Web.DistDir, cleanPath)
if info, err := os.Stat(target); err == nil && !info.IsDir() {
files.ServeHTTP(w, r)
return
}
http.ServeFile(w, r, filepath.Join(s.config.Web.DistDir, "index.html"))
})
}