Monorepo for Tangled tangled.org

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

authored by tjh.dev and committed by Tangled f884856c d5051d79

Changed files
+19
appview
+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
··· 169 169 // These routes get proxied to the knot 170 170 r.Get("/info/refs", s.InfoRefs) 171 171 r.Post("/git-upload-pack", s.UploadPack) 172 + r.Post("/git-receive-pack", s.ReceivePack) 172 173 173 174 // settings routes, needs auth 174 175 r.Group(func(r chi.Router) {