diff options
author | Emile <hanemile@protonmail.com> | 2020-03-15 22:52:03 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2020-03-15 22:52:03 +0100 |
commit | fe21df9246785473b56d31fd1bd6cec3c5372be7 (patch) | |
tree | 836feddd127bc9b9fad9c1f7d812c926aa21748e /src | |
parent | 585a7c31b8d46d4c28bf5ef2b21c0290ee0d1b51 (diff) |
more logging
Diffstat (limited to 'src')
-rw-r--r-- | src/http/http.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/http/http.go b/src/http/http.go index 83faa93..1ab3afb 100644 --- a/src/http/http.go +++ b/src/http/http.go @@ -65,11 +65,14 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { root := viper.GetString("server.root") requestURI := fmt.Sprintf("%s%s", root, r.RequestURI) + logrus.Tracef("root: %s", root) + logrus.Tracef("requestURI: %s", root) query := r.URL.Query() if query["download"] != nil { + // strip the file before and after the request strippedFile := strings.Replace(requestURI, root, "", -1) strippedFile = strings.Replace(strippedFile, "?download", "", -1) path := fmt.Sprintf("/download?file=%s", strippedFile) @@ -93,6 +96,7 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { var dirCount int = 0 var fileCount int = 0 for _, f := range files { + logrus.Tracef("f: %s", f.Name()) // get the file or dirs modtime and format it in a readable way as // described in the config @@ -137,6 +141,9 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { // ad the file and dir count to the contents map content["NumDirs"] = dirCount content["NumFiles"] = fileCount + logrus.Tracef("") + logrus.Tracef("numDirs: %d", dirCount) + logrus.Tracef("numFiles: %d", fileCount) // if there are more than one breadcrumb, define the uppath as the second // last breadcrumb @@ -159,6 +166,7 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { // if we're not at the root, we can still go futher down! if r.RequestURI != "/" { content["CanGoUp"] = "true" + logrus.Tracef("can go up") } // define a new template to render the challenges in @@ -166,10 +174,14 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { t, err = t.ParseGlob("./hosted/tmpl/*.html") if err != nil { logrus.Warn(err) + w.WriteHeader(http.StatusInternalServerError) return } - t.ExecuteTemplate(w, "index", content) + err = t.ExecuteTemplate(w, "index", content) + logrus.Warn(err) + w.WriteHeader(http.StatusInternalServerError) + return } // breadcrumbs get's the breadcrumbs from the request |