From 96c0784f99e134156be8b751607aad1e78bbc094 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 5 Apr 2025 17:41:25 +0800 Subject: HTTP: Replace if-else chain with switch --- http_handle_repo_raw.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'http_handle_repo_raw.go') 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("

README rendering here is WIP again

") // 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") } } -- cgit v1.2.3