diff options
Diffstat (limited to 'src/http')
-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 |