From 0e300e586d46fa8a32856bfe6e519828f8c17fba Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 22 Mar 2020 15:51:20 +0100 Subject: defined the view query catcher --- src/http/http.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/http/http.go') diff --git a/src/http/http.go b/src/http/http.go index 5593969..ee5434e 100644 --- a/src/http/http.go +++ b/src/http/http.go @@ -147,6 +147,22 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { return } + // if the ?view query is present, retirect to the view handler with the + // needed information + if query["view"] != nil { + + // strip the file before and after the request + strippedFile := strings.Replace(r.URL.Path, root, "", -1) + + // base64 encode the file path + strippedFileBase64 := base64.StdEncoding.EncodeToString([]byte(strippedFile)) + + path := fmt.Sprintf("/view?file=%s&hash=%s", strippedFileBase64, query["hash"][0]) + http.Redirect(w, r, path, http.StatusSeeOther) + return + } + + // define the breadcrumbs breadcrumbsList := breadcrumbs(r) content["Breadcrumbs"] = breadcrumbsList -- cgit 1.4.1