23 lines
580 B
Go

package handler
import (
"net/http"
"github.com/Neur0toxine/sshpoke/internal/api/rest/docs"
"github.com/gin-gonic/gin"
swaggerfiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
func DocsHandler() gin.HandlerFunc {
docs.SwaggerInfo.BasePath = "/api/v1"
handler := ginSwagger.WrapHandler(swaggerfiles.Handler, ginSwagger.PersistAuthorization(true))
return func(c *gin.Context) {
if c.Request.URL.Path == "/swagger" || c.Request.URL.Path == "/swagger/" {
c.Redirect(http.StatusMovedPermanently, "index.html")
return
}
handler(c)
}
}