routes: serve static content from /static
1 file changed, 12 insertions(+), 4 deletions(-)
changed files
M routes/routes.go → routes/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) +}