diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-19 01:20:19 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-19 01:20:19 +0800 |
commit | 1f27db389c23c36a5e2b8365768ed218a78e6af1 (patch) | |
tree | d4021bafb4cf5a5b092b8cb06ae389ce5b36793f /http_server.go | |
parent | contrib/index: Remove erroneous go-git/v5 (diff) | |
download | forge-1f27db389c23c36a5e2b8365768ed218a78e6af1.tar.gz forge-1f27db389c23c36a5e2b8365768ed218a78e6af1.tar.zst forge-1f27db389c23c36a5e2b8365768ed218a78e6af1.zip |
http: Add blank contrib/%d template
Diffstat (limited to 'http_server.go')
-rw-r--r-- | http_server.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/http_server.go b/http_server.go index 2bd345c..b44add3 100644 --- a/http_server.go +++ b/http_server.go @@ -45,6 +45,7 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { } params := make(map[string]any) + params["url_segments"] = segments params["global"] = global_data var _user_id int // 0 for none _user_id, params["username"], err = get_user_info_from_request(r) @@ -193,7 +194,14 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { if redirect_with_slash(w, r) { return } - handle_repo_contrib_index(w, r, params) + switch non_empty_last_segments_len { + case separator_index+4: + handle_repo_contrib_index(w, r, params) + case separator_index+5: + handle_repo_contrib_num(w, r, params) + default: + http.Error(w, "Too many parameters", http.StatusBadRequest) + } default: http.Error(w, fmt.Sprintf("Unknown repo feature: %s", repo_feature), http.StatusNotFound) } |