[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/03: Add a JSON representation for repositories
From: |
Christopher Baines |
Subject: |
02/03: Add a JSON representation for repositories |
Date: |
Sun, 27 Sep 2020 11:33:20 -0400 (EDT) |
cbaines pushed a commit to branch master
in repository data-service.
commit f7933807ac8d18b9e3d93fd4ce486900e9051f47
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sun Sep 27 16:26:45 2020 +0100
Add a JSON representation for repositories
---
guix-data-service/web/repository/controller.scm | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/guix-data-service/web/repository/controller.scm
b/guix-data-service/web/repository/controller.scm
index 7b2cb86..e8e1b52 100644
--- a/guix-data-service/web/repository/controller.scm
+++ b/guix-data-service/web/repository/controller.scm
@@ -44,9 +44,23 @@
(match method-and-path-components
(('GET "repositories")
(let ((git-repositories (all-git-repositories conn)))
- (render-html
- #:sxml
- (view-git-repositories git-repositories))))
+ (case (most-appropriate-mime-type
+ '(application/json text/html)
+ mime-types)
+ ((application/json)
+ (render-json
+ `((repositories
+ . ,(list->vector
+ (map (match-lambda
+ ((id label url cgit-base-url)
+ `((id . ,id)
+ (label . ,label)
+ (url . ,url))))
+ git-repositories))))))
+ (else
+ (render-html
+ #:sxml
+ (view-git-repositories git-repositories))))))
(('GET "repository" id)
(match (select-git-repository conn id)
((label url cgit-url-base)