summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-09-10 23:20:25 +0200
committerJulian T <julian@jtle.dk>2020-09-10 23:20:25 +0200
commit5af37b83f0204bb43218547defbf7c6c817986a6 (patch)
tree6ad8348b6dff590b19587414accecf738ce85704 /main.go
parent141f9617e4ccf54d8ab611fb1d1f57d9a42e5dbd (diff)
Root can be set in config
Diffstat (limited to 'main.go')
-rw-r--r--main.go5
1 files changed, 4 insertions, 1 deletions
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) {