From 5af37b83f0204bb43218547defbf7c6c817986a6 Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 10 Sep 2020 23:20:25 +0200 Subject: Root can be set in config --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index 0ebbdc4..12389af 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ type Config struct { Listen string `json:"listen"` DBStr string `json:"db"` TmplPath string `json:"tmpl"` + Root string `json:"root"` DataPath string `json:"data"` MaxSize uint `json:"max_upload"` @@ -210,8 +211,10 @@ func (s *Server) httpRoot(w http.ResponseWriter, r *http.Request) { Notes []note Msg string Files *map[string][]string + Root string } page.Files = &s.filestore + page.Root = s.conf.Root err := s.db.SelectContext(r.Context(), &page.Notes, ` SELECT hash, name, location FROM notes WHERE available = True`) @@ -280,7 +283,7 @@ func (s *Server) httpUpload(w http.ResponseWriter, r *http.Request) { s.saveFile(hash, fname) s.httpLog(r, "Uploaded file %s", fname) - http.Redirect(w, r, "/", http.StatusSeeOther) + http.Redirect(w, r, s.conf.Root + "/", http.StatusSeeOther) } func (s *Server) allocFile(hash string, t string) (string, error) { -- cgit v1.2.3