diff --git a/cmd/ursrv/main.go b/cmd/ursrv/main.go index 76014d268..489b4ffca 100644 --- a/cmd/ursrv/main.go +++ b/cmd/ursrv/main.go @@ -10,6 +10,7 @@ import ( "bytes" "crypto/tls" "database/sql" + "embed" "encoding/json" "html/template" "io" @@ -45,6 +46,9 @@ type CLI struct { GeoIPPath string `env:"UR_GEOIP" default:"GeoLite2-City.mmdb"` } +//go:embed static +var statics embed.FS + var ( tpl *template.Template compilerRe = regexp.MustCompile(`\(([A-Za-z0-9()., -]+) \w+-\w+(?:| android| default)\) ([\w@.-]+)`) @@ -168,7 +172,7 @@ func main() { // Template - fd, err := os.Open("static/index.html") + fd, err := statics.Open("static/index.html") if err != nil { log.Fatalln("template:", err) } @@ -224,7 +228,7 @@ func main() { http.HandleFunc("/performance.json", srv.performanceHandler) http.HandleFunc("/blockstats.json", srv.blockStatsHandler) http.HandleFunc("/locations.json", srv.locationsHandler) - http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) + http.Handle("/static/", http.FileServer(http.FS(statics))) go srv.cacheRefresher()