2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00

Add a JSON representation for repositories

This commit is contained in:
Christopher Baines 2020-09-27 16:26:45 +01:00
parent 02681d7e7a
commit f7933807ac

View file

@ -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)