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
2022-08-14 20:51:53 +02:00
committed by Benj Fassbind
parent 42cfee2c09
commit 393d1a6888
3 changed files with 27 additions and 4 deletions

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

View File

@@ -138,6 +138,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
{
root.GET("/packages/:key", apiPackagesShow)
root.GET("/packages", apiPackages)
}
{