From 1f02d49fdbe054003603c79a919f2e793e632fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Tue, 15 Oct 2024 12:09:33 +0200 Subject: [PATCH] [debian] disable swagger --- api/router.go | 52 ++++++++++++++-------------- docs/{index.go => index.go.disabled} | 0 man/aptly.1 | 3 +- man/aptly.1.ronn.tmpl | 3 +- 4 files changed, 30 insertions(+), 28 deletions(-) rename docs/{index.go => index.go.disabled} (100%) diff --git a/api/router.go b/api/router.go index 3cd7d427..c3e46c7d 100644 --- a/api/router.go +++ b/api/router.go @@ -11,9 +11,9 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/zerolog/log" - "github.com/aptly-dev/aptly/docs" - swaggerFiles "github.com/swaggo/files" - ginSwagger "github.com/swaggo/gin-swagger" + // _ "github.com/aptly-dev/aptly/docs" // import docs + // swaggerFiles "github.com/swaggo/files" + // ginSwagger "github.com/swaggo/gin-swagger" ) var context *ctx.AptlyContext @@ -25,21 +25,21 @@ func apiMetricsGet() gin.HandlerFunc { } } -func redirectSwagger(c *gin.Context) { - if c.Request.URL.Path == "/docs/index.html" { - c.Redirect(http.StatusMovedPermanently, "/docs.html") - return - } - if c.Request.URL.Path == "/docs/" { - c.Redirect(http.StatusMovedPermanently, "/docs.html") - return - } - if c.Request.URL.Path == "/docs" { - c.Redirect(http.StatusMovedPermanently, "/docs.html") - return - } - c.Next() -} +// func redirectSwagger(c *gin.Context) { +// if c.Request.URL.Path == "/docs/index.html" { +// c.Redirect(http.StatusMovedPermanently, "/docs.html") +// return +// } +// if c.Request.URL.Path == "/docs/" { +// c.Redirect(http.StatusMovedPermanently, "/docs.html") +// return +// } +// if c.Request.URL.Path == "/docs" { +// c.Redirect(http.StatusMovedPermanently, "/docs.html") +// return +// } +// c.Next() +// } // Router returns prebuilt with routes 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()) - if c.Config().EnableSwaggerEndpoint { - router.GET("docs.html", func(c *gin.Context) { - c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML) - }) - router.Use(redirectSwagger) - url := ginSwagger.URL("/docs/doc.json") - router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url)) - } + // if c.Config().EnableSwaggerEndpoint { + // router.GET("docs.html", func(c *gin.Context) { + // c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML) + // }) + // router.Use(redirectSwagger) + // url := ginSwagger.URL("/docs/doc.json") + // router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url)) + // } if c.Config().EnableMetricsEndpoint { MetricsCollectorRegistrar.Register(router) diff --git a/docs/index.go b/docs/index.go.disabled similarity index 100% rename from docs/index.go rename to docs/index.go.disabled diff --git a/man/aptly.1 b/man/aptly.1 index bd6ad223..11ed9902 100644 --- a/man/aptly.1 +++ b/man/aptly.1 @@ -111,8 +111,9 @@ The legacy json configuration is still supported (and also supports comments): // Enable metrics for Prometheus client "enableMetricsEndpoint": false, + // Not implemented in this version\. // Enable API documentation on /docs - "enableSwaggerEndpoint": false, + //"enableSwaggerEndpoint": false, // OBSOLETE: use via url param ?_async=true "AsyncAPI": false, diff --git a/man/aptly.1.ronn.tmpl b/man/aptly.1.ronn.tmpl index 203cc7fe..ed2c87c5 100644 --- a/man/aptly.1.ronn.tmpl +++ b/man/aptly.1.ronn.tmpl @@ -100,8 +100,9 @@ The legacy json configuration is still supported (and also supports comments): // Enable metrics for Prometheus client "enableMetricsEndpoint": false, + // Not implemented in this version. // Enable API documentation on /docs - "enableSwaggerEndpoint": false, + //"enableSwaggerEndpoint": false, // OBSOLETE: use via url param ?_async=true "AsyncAPI": false,