forked from tangled.org/core
this repo has no description

appview: git: proxy `git-receive-pack` requests to knotserver

Changed files
+19
appview
+18
appview/state/git_http.go
···
s.proxyRequest(w, r, targetURL)
}
+
func (s *State) ReceivePack(w http.ResponseWriter, r *http.Request) {
+
user, ok := r.Context().Value("resolvedId").(identity.Identity)
+
if !ok {
+
http.Error(w, "failed to resolve user", http.StatusInternalServerError)
+
return
+
}
+
knot := r.Context().Value("knot").(string)
+
repo := chi.URLParam(r, "repo")
+
+
scheme := "https"
+
if s.config.Core.Dev {
+
scheme = "http"
+
}
+
+
targetURL := fmt.Sprintf("%s://%s/%s/%s/git-receive-pack?%s", scheme, knot, user.DID, repo, r.URL.RawQuery)
+
s.proxyRequest(w, r, targetURL)
+
}
+
func (s *State) proxyRequest(w http.ResponseWriter, r *http.Request, targetURL string) {
client := &http.Client{}
+1
appview/state/router.go
···
// These routes get proxied to the knot
r.Get("/info/refs", s.InfoRefs)
r.Post("/git-upload-pack", s.UploadPack)
+
r.Post("/git-receive-pack", s.ReceivePack)
// settings routes, needs auth
r.Group(func(r chi.Router) {