add endpoint for listing repos while serving in api mode and add more metrics

This commit is contained in:
Markus Muellner
2023-03-20 17:14:45 +01:00
committed by Benj Fassbind
parent 0fdba29d51
commit 9c6f896666
7 changed files with 189 additions and 12 deletions
+3 -11
View File
@@ -17,6 +17,7 @@ var context *ctx.AptlyContext
func apiMetricsGet() gin.HandlerFunc {
return func(c *gin.Context) {
countPackagesByRepos()
promhttp.Handler().ServeHTTP(c.Writer, c.Request)
}
}
@@ -52,17 +53,8 @@ func Router(c *ctx.AptlyContext) http.Handler {
}
if c.Config().ServeInAPIMode {
router.GET("/repos/:storage/*pkgPath", func(c *gin.Context) {
pkgpath := c.Param("pkgPath")
storage := c.Param("storage")
if storage == "-" {
storage = ""
}
publicPath := context.GetPublishedStorage("filesystem:" + storage).(aptly.FileSystemPublishedStorage).PublicPath()
c.FileFromFS(pkgpath, http.Dir(publicPath))
})
router.GET("/repos/", reposListInAPIMode(c.Config().FileSystemPublishRoots))
router.GET("/repos/:storage/*pkgPath", reposServeInAPIMode)
}
api := router.Group("/api")