aptly
aptly copied to clipboard
Serve api and published packages simultaneously
Not sure about the reason making it two separate commands, but the following patch allows to perform both in one call.
diff --git a/api/router.go b/api/router.go
index fdfbb94..18aa742 100644
--- a/api/router.go
+++ b/api/router.go
@@ -1,6 +1,7 @@
package api
import (
+ "github.com/aptly-dev/aptly/aptly"
"net/http"
ctx "github.com/aptly-dev/aptly/context"
@@ -14,8 +15,22 @@ func Router(c *ctx.AptlyContext) http.Handler {
context = c
router := gin.Default()
+ router.RedirectTrailingSlash = false
router.Use(gin.ErrorLogger())
+ 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))
+ })
+
if context.Flags().Lookup("no-lock").Value.Get().(bool) {
// We use a goroutine to count the number of
// concurrent requests. When no more requests are
Changes are pretty minimalistic and I'd be glad to see them included. If there are no objections, I'm ready to make a PR. (disclamer: I'm not a gopher ;) )
@aol-nnov , the best way here is to propose a PR, @randombenj will be able to accpet it or not and peaple will be able to reviw your code.
Regards