aboutsummaryrefslogtreecommitdiff
path: root/http_handle_repo_index.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-18 22:59:22 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-18 22:59:45 +0800
commitc27412e76ea6627d03a57818e116c13ae8687e36 (patch)
tree19b338cdcddc2d000eaf660f3e840b702c279a89 /http_handle_repo_index.go
parentTODO: Update (e.g. potentially using fasthttp in the future) (diff)
downloadforge-c27412e76ea6627d03a57818e116c13ae8687e36.tar.gz
forge-c27412e76ea6627d03a57818e116c13ae8687e36.tar.zst
forge-c27412e76ea6627d03a57818e116c13ae8687e36.zip
http: Refactor more handler code duplication into the router
Diffstat (limited to 'http_handle_repo_index.go')
-rw-r--r--http_handle_repo_index.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/http_handle_repo_index.go b/http_handle_repo_index.go
index 448373e..cd41f50 100644
--- a/http_handle_repo_index.go
+++ b/http_handle_repo_index.go
@@ -2,16 +2,12 @@ package main
import (
"net/http"
+
+ "github.com/go-git/go-git/v5"
)
func handle_repo_index(w http.ResponseWriter, r *http.Request, params map[string]any) {
- group_name, repo_name := params["group_name"].(string), params["repo_name"].(string)
- repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
- if err != nil {
- http.Error(w, "Error opening repo: "+err.Error(), http.StatusInternalServerError)
- return
- }
- params["repo_description"] = description
+ repo, repo_name, group_name := params["repo"].(*git.Repository), params["repo_name"].(string), params["group_name"].(string)
ref_hash, err := get_ref_hash_from_type_and_name(repo, params["ref_type"].(string), params["ref_name"].(string))
if err != nil {