ability to serve any file from /static/

This commit is contained in:
Barry Deen 2024-09-10 17:17:03 -04:00
parent 559d0ca1f4
commit 489e51e274

View File

@ -112,6 +112,11 @@ func main() {
go refreshTrustNetwork(relay, ctx)
mux := relay.Router()
static := http.FileServer(http.Dir(config.StaticPath))
mux.Handle("GET /static/", http.StripPrefix("/static/", static))
mux.Handle("GET /favicon.ico", http.StripPrefix("/", static))
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.ParseFiles(os.Getenv("INDEX_PATH")))
data := struct {
@ -131,8 +136,6 @@ func main() {
}
})
mux.Handle("/favicon.ico", http.StripPrefix("/", http.FileServer(http.Dir(config.StaticPath))))
log.Println("🎉 relay running on port :3334")
err := http.ListenAndServe(":3334", relay)
if err != nil {