embed static files
1 file changed, 5 insertions(+), 2 deletions(-)
changed files
M routes/handler.go → routes/handler.go
@@ -1,6 +1,7 @@ package routes import ( + "io/fs" "log" "net/http" "path"@@ -58,7 +59,7 @@ } } } -func Handlers(c *config.Config) *httptreemux.TreeMux { +func Handlers(c *config.Config, staticFiles fs.FS) *httptreemux.TreeMux { mux := httptreemux.New() plist := filepath.Join(c.Repo.Root, "projects.list")@@ -111,7 +112,9 @@ mux.RedirectTrailingSlash = false mux.GET("/", d.Index) - mux.GET("/static/:file", d.ServeStatic) + mux.NewGroup("/static/"). + UsingContext(). + Handler("GET", "/*", http.FileServerFS(staticFiles)) mux.GET("/:name/tree/:ref/*rest", d.RepoTree) mux.GET("/:name/blob/:ref/*rest", d.FileContent)