all repos — elgit @ 7bea4a8f49a9f3aa9386b7e7d24a2a78beb2f7e9

fork of legit: web frontend for git, written in go

embed static files

Alan Pearce
commit

7bea4a8f49a9f3aa9386b7e7d24a2a78beb2f7e9

parent

5ff42d78653ea018f8855de4768cf872ce41e41e

1 file changed, 5 insertions(+), 2 deletions(-)

changed files
M routes/handler.goroutes/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)