From 489e51e27457f82c26271b96d65977af1b7f8ec1 Mon Sep 17 00:00:00 2001 From: Barry Deen Date: Tue, 10 Sep 2024 17:17:03 -0400 Subject: [PATCH] ability to serve any file from /static/ --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 0ff9339..e46445d 100644 --- a/main.go +++ b/main.go @@ -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 {