File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed
Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change 44 "encoding/json"
55 "log"
66 "net/http"
7- "os"
8- "path/filepath"
97 "strings"
108)
119
@@ -44,7 +42,7 @@ func (s *Server) Start(addr string) error {
4442 })
4543
4644 // Serve static UI files
47- fs := http .FileServer (http . Dir ( "internal/analyzer/ui" ))
45+ fs := http .FileServer (getUIFileSystem ( ))
4846 http .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
4947 // If the request is for an API endpoint, return 404
5048 if strings .HasPrefix (r .URL .Path , "/api/" ) {
@@ -54,10 +52,9 @@ func (s *Server) Start(addr string) error {
5452
5553 // For all other requests, serve the UI
5654 // If the path doesn't exist, serve index.html for client-side routing
57- path := filepath .Join ("internal/analyzer/ui" , r .URL .Path )
58- if _ , err := os .Stat (path ); err != nil {
59- http .ServeFile (w , r , "internal/analyzer/ui/index.html" )
60- return
55+ path := r .URL .Path
56+ if path == "/" {
57+ path = "/index.html"
6158 }
6259 fs .ServeHTTP (w , r )
6360 })
Original file line number Diff line number Diff line change 1+ package analyzer
2+
3+ import (
4+ "embed"
5+ "io/fs"
6+ "net/http"
7+ )
8+
9+ //go:embed ui
10+ var uiFS embed.FS
11+
12+ // getUIFileSystem returns a http.FileSystem for the embedded UI files
13+ func getUIFileSystem () http.FileSystem {
14+ // Get the subdirectory "ui" from the embedded filesystem
15+ subFS , err := fs .Sub (uiFS , "ui" )
16+ if err != nil {
17+ panic (err )
18+ }
19+ return http .FS (subFS )
20+ }
You can’t perform that action at this time.
0 commit comments