Live video on the AT Protocol
1package api 2 3import ( 4 "context" 5 "encoding/json" 6 "fmt" 7 "net/http" 8 9 "github.com/julienschmidt/httprouter" 10 "stream.place/streamplace/pkg/log" 11) 12 13func (a *StreamplaceAPI) HandleDidJSON(ctx context.Context) httprouter.Handle { 14 return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) { 15 host := req.Host 16 didJSON := map[string]any{ 17 "@context": []string{ 18 "https://www.w3.org/ns/did/v1", 19 }, 20 "id": fmt.Sprintf("did:web:%s", host), 21 "service": []map[string]any{ 22 { 23 "id": "#bsky_fg", 24 "type": "BskyFeedGenerator", 25 "serviceEndpoint": fmt.Sprintf("https://%s", host), 26 }, 27 }, 28 } 29 w.WriteHeader(200) 30 w.Header().Set("Content-Type", "application/json") 31 bs, err := json.Marshal(didJSON) 32 if err != nil { 33 log.Error(ctx, "could not marshal did json", "error", err) 34 return 35 } 36 if _, err := w.Write(bs); err != nil { 37 log.Error(ctx, "error writing response", "error", err) 38 } 39 } 40}