api: Allow querying the packages endpoint

The ".../packages" endpoints for mirror, local repos and snapshots all
share the same syntax for querying. However the "/api/packages" endpoint
doesn't match this. Adjust that to allow for a bit more consistency and
allow querying the full package database.

The current endpoint functionality "/packages/:name" is kept intact and
can be used the same as now

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
This commit is contained in:
Sjoerd Simons authored and Benj Fassbind committed 2022-08-29 10:28:44 +02:00
1 parent 42cfee2c09
commit 393d1a6888
3 files changed
+27 -4

No files matched your search

+7
View File
@@ -15,3 +15,10 @@ func apiPackagesShow(c *gin.Context) {
c.JSON(200, p)
}
// GET /api/packages
func apiPackages(c *gin.Context) {
collectionFactory := context.NewCollectionFactory()
collection := collectionFactory.PackageCollection()
showPackages(c, collection.AllPackageRefs(), collectionFactory)
}
+1
View File
@@ -138,6 +138,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
{
root.GET("/packages/:key", apiPackagesShow)
root.GET("/packages", apiPackages)
}
{