diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2024-02-25 23:15:21 +0200 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2024-02-25 23:15:21 +0200 |
commit | a87f88a57c68627a1f63f1551fcef2c1f1ec7036 (patch) | |
tree | 232d2d89b717c6368008e9ab3f7dec569b62fb18 /routes/routes.go | |
parent | deps: bump go-git (diff) | |
download | legitrx-a87f88a57c68627a1f63f1551fcef2c1f1ec7036.tar.gz legitrx-a87f88a57c68627a1f63f1551fcef2c1f1ec7036.tar.zst legitrx-a87f88a57c68627a1f63f1551fcef2c1f1ec7036.zip |
routes: add raw file view
Diffstat (limited to 'routes/routes.go')
-rw-r--r-- | routes/routes.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/routes/routes.go b/routes/routes.go index 0499a9e..2989752 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "sort" + "strconv" "time" "git.icyphox.sh/legit/config" @@ -199,6 +200,11 @@ func (d *deps) RepoTree(w http.ResponseWriter, r *http.Request) { } func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) { + var raw bool + if rawParam, err := strconv.ParseBool(r.URL.Query().Get("raw")); err == nil { + raw = rawParam + } + name := flow.Param(r.Context(), "name") if d.isIgnored(name) { d.Write404(w) @@ -222,7 +228,11 @@ func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) { data["desc"] = getDescription(path) data["path"] = treePath - d.showFile(contents, data, w) + if raw { + d.showRaw(contents, w) + } else { + d.showFile(contents, data, w) + } return } |