Sybren A. Stüvel 7d64d1bca4 Move SwaggerUI to /api/v3/swagger-ui
Include the `v3` path component in the Swagger UI URL.
2022-07-04 12:21:18 +02:00

26 lines
548 B
Go

package swagger_ui
import (
"embed"
"io/fs"
"net/http"
"github.com/labstack/echo/v4"
"github.com/rs/zerolog/log"
)
//go:embed static
var swaggerUI embed.FS
const swaggerURL = "/api/v3/swagger-ui/"
func RegisterSwaggerUIStaticFiles(router *echo.Echo) {
files, err := fs.Sub(swaggerUI, "static")
if err != nil {
log.Fatal().Err(err).Msg("error preparing embedded files for serving over HTTP")
}
httpHandler := http.FileServer(http.FS(files))
router.GET(swaggerURL+"*", echo.WrapHandler(http.StripPrefix(swaggerURL, httpHandler)))
}