tangled
alpha
login
or
join now
julien.rbrt.fr
/
tangled-core
forked from
tangled.org/core
0
fork
atom
Monorepo for Tangled — https://tangled.org
0
fork
atom
overview
issues
pulls
pipelines
introduce capabilities to knotserver
oppi.li
11 months ago
9b8e8d4a
713ecb82
+33
3 changed files
expand all
collapse all
unified
split
appview
state
signer.go
knotserver
handler.go
routes.go
+14
appview/state/signer.go
···
268
268
269
269
return us.client.Do(req)
270
270
}
271
271
+
272
272
+
func (us *UnsignedClient) Capabilities(ownerDid, repoName string) (*http.Response, error) {
273
273
+
const (
274
274
+
Method = "GET"
275
275
+
Endpoint = "/capabilities"
276
276
+
)
277
277
+
278
278
+
req, err := us.newRequest(Method, Endpoint, nil)
279
279
+
if err != nil {
280
280
+
return nil, err
281
281
+
}
282
282
+
283
283
+
return us.client.Do(req)
284
284
+
}
+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")