From f34697bc9d6c9e25ca04b36f1782de90aa31571f Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 09 Feb 2025 02:16:39 +0800 Subject: [PATCH] {main,resources}.go: Serve static/ properly --- main.go | 5 +++++ resources.go | 2 +- diff --git a/main.go b/main.go index c2eb32824144112a926df8578ab5d2fc1da9c928..d3d1fbee09c9e8c998cca62015cbe1dc80185ed3 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,11 @@ err = load_templates() if err != nil { clog.Fatal(1, "Loading templates: "+err.Error()) } + + err = serve_static() + if err != nil { + clog.Fatal(1, "Serving static: "+err.Error()) + } http.HandleFunc("/{$}", handle_index) http.HandleFunc("/{project_name}/repos/{repo_name}/", handle_repo_index) diff --git a/resources.go b/resources.go index 737a079e699d86937bc6fcc3a307f2cc83d5de0d..b7ccca6c6372daf60e2f7974a48e3616ec2a6ee4 100644 --- a/resources.go +++ b/resources.go @@ -22,7 +22,7 @@ static_fs, err := fs.Sub(resources_fs, "static") if err != nil { return err } - http.Handle("/static/", + http.Handle("/static/{name}", http.StripPrefix( "/static/", http.FileServer(http.FS(static_fs)), -- 2.48.1