mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
cmd/ursrv: Embed static assets
This commit is contained in:
parent
bf61e485a6
commit
2fcf7006e6
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user