aboutsummaryrefslogtreecommitdiff
path: root/http_server.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-14 11:15:24 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-14 11:15:36 +0800
commit66b05d8daf931e34d934bc33e882183aec538a8a (patch)
treeafdc300d29fe21e39bf96a3553ba5da3e68f5ce1 /http_server.go
parentstyle.css: Categorize CSS statements (diff)
downloadforge-66b05d8daf931e34d934bc33e882183aec538a8a.tar.gz
forge-66b05d8daf931e34d934bc33e882183aec538a8a.tar.zst
forge-66b05d8daf931e34d934bc33e882183aec538a8a.zip
http_server.go: Rename dir_mode to trailing_slash
Diffstat (limited to '')
-rw-r--r--http_server.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/http_server.go b/http_server.go
index 6626ae4..fc92ef1 100644
--- a/http_server.go
+++ b/http_server.go
@@ -22,17 +22,17 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
non_empty_last_segments_len := len(segments)
- dir_mode := false
+ trailing_slash := false
if segments[len(segments)-1] == "" {
non_empty_last_segments_len--
- dir_mode = true
+ trailing_slash = true
}
if segments[0] == ":" {
if len(segments) < 2 {
http.Error(w, "Blank system endpoint", http.StatusNotFound)
return
- } else if len(segments) == 2 && !dir_mode {
+ } else if len(segments) == 2 && !trailing_slash {
http.Redirect(w, r, r.URL.Path+"/", http.StatusSeeOther)
return
}
@@ -94,7 +94,7 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case non_empty_last_segments_len == separator_index+1:
http.Error(w, "Group root hasn't been implemented yet", http.StatusNotImplemented)
case non_empty_last_segments_len == separator_index+2:
- if !dir_mode {
+ if !trailing_slash {
http.Redirect(w, r, r.URL.Path+"/", http.StatusSeeOther)
return
}
@@ -124,7 +124,7 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
// TODO: subgroups
if non_empty_last_segments_len == separator_index+3 {
- if !dir_mode {
+ if !trailing_slash {
http.Redirect(w, r, r.URL.Path+"/", http.StatusSeeOther)
return
}
@@ -149,14 +149,14 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Insufficient parameters", http.StatusBadRequest)
return
}
- if dir_mode {
+ if trailing_slash {
http.Redirect(w, r, strings.TrimSuffix(r.URL.Path, "/"), http.StatusSeeOther)
return
}
params["ref_name"] = segments[separator_index+4]
handle_repo_log(w, r, params)
case "commit":
- if dir_mode {
+ if trailing_slash {
http.Redirect(w, r, strings.TrimSuffix(r.URL.Path, "/"), http.StatusSeeOther)
return
}