mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-26 13:47:40 +00:00
make serving published repos in api mode configurable
This commit is contained in:
committed by
Benj Fassbind
parent
f74217ed9c
commit
0fdba29d51
+11
-10
@@ -51,18 +51,19 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
|||||||
MetricsCollectorRegistrar.Register(router)
|
MetricsCollectorRegistrar.Register(router)
|
||||||
}
|
}
|
||||||
|
|
||||||
router.GET("/repos/:storage/*pkgPath", func(c *gin.Context) {
|
if c.Config().ServeInAPIMode {
|
||||||
pkgpath := c.Param("pkgPath")
|
router.GET("/repos/:storage/*pkgPath", func(c *gin.Context) {
|
||||||
|
pkgpath := c.Param("pkgPath")
|
||||||
|
|
||||||
storage := c.Param("storage")
|
storage := c.Param("storage")
|
||||||
if storage == "-" {
|
if storage == "-" {
|
||||||
storage = ""
|
storage = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
publicPath := context.GetPublishedStorage("filesystem:" + storage).(aptly.FileSystemPublishedStorage).PublicPath()
|
publicPath := context.GetPublishedStorage("filesystem:" + storage).(aptly.FileSystemPublishedStorage).PublicPath()
|
||||||
|
c.FileFromFS(pkgpath, http.Dir(publicPath))
|
||||||
c.FileFromFS(pkgpath, http.Dir(publicPath))
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
api := router.Group("/api")
|
api := router.Group("/api")
|
||||||
if context.Flags().Lookup("no-lock").Value.Get().(bool) {
|
if context.Flags().Lookup("no-lock").Value.Get().(bool) {
|
||||||
|
|||||||
+2
-1
@@ -148,7 +148,8 @@ class BaseTest(object):
|
|||||||
"ppaCodename": "",
|
"ppaCodename": "",
|
||||||
"enableMetricsEndpoint": True,
|
"enableMetricsEndpoint": True,
|
||||||
"logLevel": "debug",
|
"logLevel": "debug",
|
||||||
"logFormat": "default"
|
"logFormat": "default",
|
||||||
|
"serveInAPIMode": True
|
||||||
}
|
}
|
||||||
configOverride = {}
|
configOverride = {}
|
||||||
environmentOverride = {}
|
environmentOverride = {}
|
||||||
|
|||||||
@@ -27,5 +27,6 @@
|
|||||||
"AsyncAPI": false,
|
"AsyncAPI": false,
|
||||||
"enableMetricsEndpoint": true,
|
"enableMetricsEndpoint": true,
|
||||||
"logLevel": "debug",
|
"logLevel": "debug",
|
||||||
"logFormat": "default"
|
"logFormat": "default",
|
||||||
|
"serveInAPIMode": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,5 +27,6 @@
|
|||||||
"AsyncAPI": false,
|
"AsyncAPI": false,
|
||||||
"enableMetricsEndpoint": false,
|
"enableMetricsEndpoint": false,
|
||||||
"logLevel": "debug",
|
"logLevel": "debug",
|
||||||
"logFormat": "default"
|
"logFormat": "default",
|
||||||
|
"serveInAPIMode": false
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,7 @@ type ConfigStructure struct { // nolint: maligned
|
|||||||
EnableMetricsEndpoint bool `json:"enableMetricsEndpoint"`
|
EnableMetricsEndpoint bool `json:"enableMetricsEndpoint"`
|
||||||
LogLevel string `json:"logLevel"`
|
LogLevel string `json:"logLevel"`
|
||||||
LogFormat string `json:"logFormat"`
|
LogFormat string `json:"logFormat"`
|
||||||
|
ServeInAPIMode bool `json:"serveInAPIMode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileSystemPublishRoot describes single filesystem publishing entry point
|
// FileSystemPublishRoot describes single filesystem publishing entry point
|
||||||
@@ -116,6 +117,7 @@ var Config = ConfigStructure{
|
|||||||
EnableMetricsEndpoint: false,
|
EnableMetricsEndpoint: false,
|
||||||
LogLevel: "debug",
|
LogLevel: "debug",
|
||||||
LogFormat: "default",
|
LogFormat: "default",
|
||||||
|
ServeInAPIMode: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfig loads configuration from json file
|
// LoadConfig loads configuration from json file
|
||||||
|
|||||||
@@ -136,7 +136,8 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
|
|||||||
" \"AsyncAPI\": false,\n"+
|
" \"AsyncAPI\": false,\n"+
|
||||||
" \"enableMetricsEndpoint\": false,\n"+
|
" \"enableMetricsEndpoint\": false,\n"+
|
||||||
" \"logLevel\": \"info\",\n"+
|
" \"logLevel\": \"info\",\n"+
|
||||||
" \"logFormat\": \"json\"\n"+
|
" \"logFormat\": \"json\",\n"+
|
||||||
|
" \"serveInAPIMode\": false\n"+
|
||||||
"}")
|
"}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user