+18
appview/state/git_http.go
+18
appview/state/git_http.go
···
42
42
s.proxyRequest(w, r, targetURL)
43
43
}
44
44
45
+
func (s *State) ReceivePack(w http.ResponseWriter, r *http.Request) {
46
+
user, ok := r.Context().Value("resolvedId").(identity.Identity)
47
+
if !ok {
48
+
http.Error(w, "failed to resolve user", http.StatusInternalServerError)
49
+
return
50
+
}
51
+
knot := r.Context().Value("knot").(string)
52
+
repo := chi.URLParam(r, "repo")
53
+
54
+
scheme := "https"
55
+
if s.config.Core.Dev {
56
+
scheme = "http"
57
+
}
58
+
59
+
targetURL := fmt.Sprintf("%s://%s/%s/%s/git-receive-pack?%s", scheme, knot, user.DID, repo, r.URL.RawQuery)
60
+
s.proxyRequest(w, r, targetURL)
61
+
}
62
+
45
63
func (s *State) proxyRequest(w http.ResponseWriter, r *http.Request, targetURL string) {
46
64
client := &http.Client{}
47
65
+1
appview/state/router.go
+1
appview/state/router.go