diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-17 12:45:21 +0530 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-17 12:45:21 +0530 |
commit | d083d5d72e4bf496b8152d14986818a5b63fe301 (patch) | |
tree | ae5dbe4a26ca13a66e02f1c67229548913433c27 /routes/routes.go | |
parent | b833d2f73d5f4e56d7e082495c44d394d2361cbd (diff) | |
download | legit-d083d5d72e4bf496b8152d14986818a5b63fe301.tar.gz legit-d083d5d72e4bf496b8152d14986818a5b63fe301.tar.bz2 legit-d083d5d72e4bf496b8152d14986818a5b63fe301.zip |
routes: serve static content from /static
Diffstat (limited to 'routes/routes.go')
-rw-r--r-- | routes/routes.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/routes/routes.go b/routes/routes.go index aab28f5..5a8d686 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -42,6 +42,7 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) { if err != nil { d.Write500(w) log.Println(err) + return } var desc string @@ -59,7 +60,7 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) { }) } - 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 @@ func (d *deps) Log(w http.ResponseWriter, r *http.Request) { 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 @@ func (d *deps) Diff(w http.ResponseWriter, r *http.Request) { 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 @@ func (d *deps) Refs(w http.ResponseWriter, r *http.Request) { 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 @@ func (d *deps) Refs(w http.ResponseWriter, r *http.Request) { 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) +} |