tangled
alpha
login
or
join now
willdot.net
/
tangled-fork
forked from
tangled.org/core
Monorepo for Tangled
0
fork
atom
overview
issues
pulls
pipelines
introduce capabilities to knotserver
oppi.li
10 months ago
d3bf20a0
f129b4f1
+33
3 changed files
expand all
collapse all
unified
split
appview
state
signer.go
knotserver
handler.go
routes.go
+14
appview/state/signer.go
···
301
301
302
302
return us.client.Do(req)
303
303
}
304
304
+
305
305
+
func (us *UnsignedClient) Capabilities(ownerDid, repoName string) (*http.Response, error) {
306
306
+
const (
307
307
+
Method = "GET"
308
308
+
Endpoint = "/capabilities"
309
309
+
)
310
310
+
311
311
+
req, err := us.newRequest(Method, Endpoint, nil)
312
312
+
if err != nil {
313
313
+
return nil, err
314
314
+
}
315
315
+
316
316
+
return us.client.Do(req)
317
317
+
}
+1
knotserver/handler.go
···
70
70
}
71
71
72
72
r.Get("/", h.Index)
73
73
+
r.Get("/capabilities", h.Capabilities)
73
74
r.Get("/version", h.Version)
74
75
r.Route("/{did}", func(r chi.Router) {
75
76
// Repo routes
+18
knotserver/routes.go
···
31
31
w.Write([]byte("This is a knot server. More info at https://tangled.sh"))
32
32
}
33
33
34
34
+
func (h *Handle) Capabilities(w http.ResponseWriter, r *http.Request) {
35
35
+
w.Header().Set("Content-Type", "application/json")
36
36
+
37
37
+
capabilities := map[string]any{
38
38
+
"pull_requests": map[string]any{
39
39
+
"patch_submissions": true,
40
40
+
},
41
41
+
}
42
42
+
43
43
+
jsonData, err := json.Marshal(capabilities)
44
44
+
if err != nil {
45
45
+
http.Error(w, "Failed to serialize JSON", http.StatusInternalServerError)
46
46
+
return
47
47
+
}
48
48
+
49
49
+
w.Write(jsonData)
50
50
+
}
51
51
+
34
52
func (h *Handle) RepoIndex(w http.ResponseWriter, r *http.Request) {
35
53
path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r))
36
54
l := h.l.With("path", path, "handler", "RepoIndex")