all repos — elgit @ d083d5d72e4bf496b8152d14986818a5b63fe301

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

routes: serve static content from /static

commit

d083d5d72e4bf496b8152d14986818a5b63fe301

parent

b833d2f73d5f4e56d7e082495c44d394d2361cbd

1 file changed, 12 insertions(+), 4 deletions(-)

changed files
M routes/routes.goroutes/routes.go
@@ -42,6 +42,7 @@ c, err := gr.LastCommit()
if err != nil { d.Write500(w) log.Println(err) + return } var desc string
@@ -59,7 +60,7 @@ Idle: humanize.Time(c.Author.When),
}) } - tpath := filepath.Join(d.c.Template.Dir, "*") + tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) data := make(map[string]interface{})
@@ -186,7 +187,7 @@ log.Println(err)
return } - tpath := filepath.Join(d.c.Template.Dir, "*") + tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) data := make(map[string]interface{})
@@ -219,7 +220,7 @@ log.Println(err)
return } - tpath := filepath.Join(d.c.Template.Dir, "*") + tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) data := make(map[string]interface{})
@@ -260,7 +261,7 @@ d.Write500(w)
return } - tpath := filepath.Join(d.c.Template.Dir, "*") + tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) data := make(map[string]interface{})
@@ -275,3 +276,10 @@ log.Println(err)
return } } + +func (d *deps) ServeStatic(w http.ResponseWriter, r *http.Request) { + f := flow.Param(r.Context(), "file") + f = filepath.Clean(filepath.Join(d.c.Dirs.Static, f)) + + http.ServeFile(w, r, f) +}