mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
393d1a6888
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>
25 lines
565 B
Go
25 lines
565 B
Go
package api
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// GET /api/packages/:key
|
|
func apiPackagesShow(c *gin.Context) {
|
|
collectionFactory := context.NewCollectionFactory()
|
|
p, err := collectionFactory.PackageCollection().ByKey([]byte(c.Params.ByName("key")))
|
|
if err != nil {
|
|
c.AbortWithError(404, err)
|
|
return
|
|
}
|
|
|
|
c.JSON(200, p)
|
|
}
|
|
|
|
// GET /api/packages
|
|
func apiPackages(c *gin.Context) {
|
|
collectionFactory := context.NewCollectionFactory()
|
|
collection := collectionFactory.PackageCollection()
|
|
showPackages(c, collection.AllPackageRefs(), collectionFactory)
|
|
}
|