diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-05 17:41:25 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-05 17:41:25 +0800 |
commit | 96c0784f99e134156be8b751607aad1e78bbc094 (patch) | |
tree | 16b393f90ef5005b86af9a5f90af89d028d2e544 /http_handle_repo_raw.go | |
parent | Remove current caching mechanisms (diff) | |
download | forge-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.go | 7 |
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") } } |