aboutsummaryrefslogtreecommitdiff
path: root/http_handle_repo_raw.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 17:41:25 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 17:41:25 +0800
commit96c0784f99e134156be8b751607aad1e78bbc094 (patch)
tree16b393f90ef5005b86af9a5f90af89d028d2e544 /http_handle_repo_raw.go
parentRemove current caching mechanisms (diff)
downloadforge-96c0784f99e134156be8b751607aad1e78bbc094.tar.gz
forge-96c0784f99e134156be8b751607aad1e78bbc094.tar.zst
forge-96c0784f99e134156be8b751607aad1e78bbc094.zip
HTTP: Replace if-else chain with switch
Diffstat (limited to 'http_handle_repo_raw.go')
-rw-r--r--http_handle_repo_raw.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/http_handle_repo_raw.go b/http_handle_repo_raw.go
index 54ca931..ea2925c 100644
--- a/http_handle_repo_raw.go
+++ b/http_handle_repo_raw.go
@@ -36,18 +36,19 @@ func httpHandleRepoRaw(writer http.ResponseWriter, request *http.Request, params
return
}
- if files != nil {
+ switch {
+ case files != nil:
params["files"] = files
params["readme_filename"] = "README.md"
params["readme"] = template.HTML("<p>README rendering here is WIP again</p>") // TODO
renderTemplate(writer, "repo_raw_dir", params)
- } else if content != "" {
+ case content != "":
if redirectNoDir(writer, request) {
return
}
writer.Header().Set("Content-Type", "application/octet-stream")
fmt.Fprint(writer, content)
- } else {
+ default:
errorPage500(writer, params, "Unknown error fetching repo raw data")
}
}