diff --git a/appview/state/signer.go b/appview/state/signer.go index 6ce2aefe..70158720 100644 --- a/appview/state/signer.go +++ b/appview/state/signer.go @@ -301,3 +301,17 @@ func (us *UnsignedClient) DefaultBranch(ownerDid, repoName string) (*http.Respon return us.client.Do(req) } + +func (us *UnsignedClient) Capabilities(ownerDid, repoName string) (*http.Response, error) { + const ( + Method = "GET" + Endpoint = "/capabilities" + ) + + req, err := us.newRequest(Method, Endpoint, nil) + if err != nil { + return nil, err + } + + return us.client.Do(req) +} diff --git a/knotserver/handler.go b/knotserver/handler.go index 5be0725d..8df4eafd 100644 --- a/knotserver/handler.go +++ b/knotserver/handler.go @@ -70,6 +70,7 @@ func Setup(ctx context.Context, c *config.Config, db *db.DB, e *rbac.Enforcer, j } r.Get("/", h.Index) + r.Get("/capabilities", h.Capabilities) r.Get("/version", h.Version) r.Route("/{did}", func(r chi.Router) { // Repo routes diff --git a/knotserver/routes.go b/knotserver/routes.go index 147a06b5..055a4923 100644 --- a/knotserver/routes.go +++ b/knotserver/routes.go @@ -31,6 +31,24 @@ func (h *Handle) Index(w http.ResponseWriter, r *http.Request) { w.Write([]byte("This is a knot server. More info at https://tangled.sh")) } +func (h *Handle) Capabilities(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + + capabilities := map[string]any{ + "pull_requests": map[string]any{ + "patch_submissions": true, + }, + } + + jsonData, err := json.Marshal(capabilities) + if err != nil { + http.Error(w, "Failed to serialize JSON", http.StatusInternalServerError) + return + } + + w.Write(jsonData) +} + func (h *Handle) RepoIndex(w http.ResponseWriter, r *http.Request) { path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r)) l := h.l.With("path", path, "handler", "RepoIndex")