this repo has no description
1package state
2
3import (
4 "fmt"
5 "io"
6 "log"
7 "net/http"
8
9 "github.com/bluesky-social/indigo/atproto/identity"
10 "github.com/go-chi/chi/v5"
11)
12
13func (s *State) RepoIndex(w http.ResponseWriter, r *http.Request) {
14 ctx := r.Context()
15 repoName := chi.URLParam(r, "repo")
16
17 domain, ok := ctx.Value("domain").(string)
18 if !ok {
19 log.Println("malformed middleware")
20 w.WriteHeader(http.StatusInternalServerError)
21 return
22 }
23
24 id, ok := ctx.Value("resolvedId").(identity.Identity)
25 if !ok {
26 log.Println("malformed middleware")
27 w.WriteHeader(http.StatusInternalServerError)
28 return
29 }
30
31 resp, err := http.Get(fmt.Sprintf("http://%s/%s/%s", domain, id.DID.String(), repoName))
32 if err != nil {
33 log.Println("failed to reach knotserver", err)
34 return
35 }
36
37 txt, err := io.ReadAll(resp.Body)
38 log.Println(resp.Status, string(txt))
39
40 return
41}