mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-16 12:08:04 +00:00
[debian] disable swagger
This commit is contained in:
+26
-26
@@ -11,9 +11,9 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/aptly-dev/aptly/docs"
|
// _ "github.com/aptly-dev/aptly/docs" // import docs
|
||||||
swaggerFiles "github.com/swaggo/files"
|
// swaggerFiles "github.com/swaggo/files"
|
||||||
ginSwagger "github.com/swaggo/gin-swagger"
|
// ginSwagger "github.com/swaggo/gin-swagger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var context *ctx.AptlyContext
|
var context *ctx.AptlyContext
|
||||||
@@ -25,21 +25,21 @@ func apiMetricsGet() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func redirectSwagger(c *gin.Context) {
|
// func redirectSwagger(c *gin.Context) {
|
||||||
if c.Request.URL.Path == "/docs/index.html" {
|
// if c.Request.URL.Path == "/docs/index.html" {
|
||||||
c.Redirect(http.StatusMovedPermanently, "/docs.html")
|
// c.Redirect(http.StatusMovedPermanently, "/docs.html")
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if c.Request.URL.Path == "/docs/" {
|
// if c.Request.URL.Path == "/docs/" {
|
||||||
c.Redirect(http.StatusMovedPermanently, "/docs.html")
|
// c.Redirect(http.StatusMovedPermanently, "/docs.html")
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if c.Request.URL.Path == "/docs" {
|
// if c.Request.URL.Path == "/docs" {
|
||||||
c.Redirect(http.StatusMovedPermanently, "/docs.html")
|
// c.Redirect(http.StatusMovedPermanently, "/docs.html")
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
c.Next()
|
// c.Next()
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Router returns prebuilt with routes http.Handler
|
// Router returns prebuilt with routes http.Handler
|
||||||
func Router(c *ctx.AptlyContext) http.Handler {
|
func Router(c *ctx.AptlyContext) http.Handler {
|
||||||
@@ -63,14 +63,14 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
|||||||
|
|
||||||
router.Use(gin.Recovery(), gin.ErrorLogger())
|
router.Use(gin.Recovery(), gin.ErrorLogger())
|
||||||
|
|
||||||
if c.Config().EnableSwaggerEndpoint {
|
// if c.Config().EnableSwaggerEndpoint {
|
||||||
router.GET("docs.html", func(c *gin.Context) {
|
// router.GET("docs.html", func(c *gin.Context) {
|
||||||
c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML)
|
// c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML)
|
||||||
})
|
// })
|
||||||
router.Use(redirectSwagger)
|
// router.Use(redirectSwagger)
|
||||||
url := ginSwagger.URL("/docs/doc.json")
|
// url := ginSwagger.URL("/docs/doc.json")
|
||||||
router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
|
// router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
|
||||||
}
|
// }
|
||||||
|
|
||||||
if c.Config().EnableMetricsEndpoint {
|
if c.Config().EnableMetricsEndpoint {
|
||||||
MetricsCollectorRegistrar.Register(router)
|
MetricsCollectorRegistrar.Register(router)
|
||||||
|
|||||||
+2
-1
@@ -111,8 +111,9 @@ The legacy json configuration is still supported (and also supports comments):
|
|||||||
// Enable metrics for Prometheus client
|
// Enable metrics for Prometheus client
|
||||||
"enableMetricsEndpoint": false,
|
"enableMetricsEndpoint": false,
|
||||||
|
|
||||||
|
// Not implemented in this version\.
|
||||||
// Enable API documentation on /docs
|
// Enable API documentation on /docs
|
||||||
"enableSwaggerEndpoint": false,
|
//"enableSwaggerEndpoint": false,
|
||||||
|
|
||||||
// OBSOLETE: use via url param ?_async=true
|
// OBSOLETE: use via url param ?_async=true
|
||||||
"AsyncAPI": false,
|
"AsyncAPI": false,
|
||||||
|
|||||||
@@ -100,8 +100,9 @@ The legacy json configuration is still supported (and also supports comments):
|
|||||||
// Enable metrics for Prometheus client
|
// Enable metrics for Prometheus client
|
||||||
"enableMetricsEndpoint": false,
|
"enableMetricsEndpoint": false,
|
||||||
|
|
||||||
|
// Not implemented in this version.
|
||||||
// Enable API documentation on /docs
|
// Enable API documentation on /docs
|
||||||
"enableSwaggerEndpoint": false,
|
//"enableSwaggerEndpoint": false,
|
||||||
|
|
||||||
// OBSOLETE: use via url param ?_async=true
|
// OBSOLETE: use via url param ?_async=true
|
||||||
"AsyncAPI": false,
|
"AsyncAPI": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user