diff --git a/api/router.go b/api/router.go index 595f43171..35f0f36f8 100644 --- a/api/router.go +++ b/api/router.go @@ -12,7 +12,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/zerolog/log" - _ "github.com/aptly-dev/aptly/docs" // import docs + "github.com/aptly-dev/aptly/docs" swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" ) @@ -27,15 +27,22 @@ 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/index.html") + 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 { if aptly.EnableDebug { gin.SetMode(gin.DebugMode) @@ -62,6 +69,9 @@ 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)) diff --git a/docs/Status.md b/docs/Status.md new file mode 100644 index 000000000..72162d961 --- /dev/null +++ b/docs/Status.md @@ -0,0 +1,5 @@ +
+## Aptly Status Information +
+ +asd wer diff --git a/docs/docs.html b/docs/docs.html new file mode 100644 index 000000000..b614a2e59 --- /dev/null +++ b/docs/docs.html @@ -0,0 +1,104 @@ + + + + + Swagger UI + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + diff --git a/docs/index.go b/docs/index.go new file mode 100644 index 000000000..4a09caeb7 --- /dev/null +++ b/docs/index.go @@ -0,0 +1,8 @@ +package docs + +import ( + _ "embed" +) + +//go:embed docs.html +var DocsHTML []byte