aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web/repository
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-09-27 16:26:45 +0100
committerChristopher Baines <mail@cbaines.net>2020-09-27 16:26:45 +0100
commitf7933807ac8d18b9e3d93fd4ce486900e9051f47 (patch)
tree24caf8dabfd704171fdc983a057870f346e96011 /guix-data-service/web/repository
parent02681d7e7ab9823a51e0a3af0bf474b9a08bdcc2 (diff)
downloaddata-service-f7933807ac8d18b9e3d93fd4ce486900e9051f47.tar
data-service-f7933807ac8d18b9e3d93fd4ce486900e9051f47.tar.gz
Add a JSON representation for repositories
Diffstat (limited to 'guix-data-service/web/repository')
-rw-r--r--guix-data-service/web/repository/controller.scm20
1 files 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)