-
Notifications
You must be signed in to change notification settings - Fork 132
Blank page when using Gzip middleware #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Turned out we can skip the middleware only for swagger.
|
Added the solution to problem with blank page when using gzip to documents for better visibility swaggoGH-19
Hi I'm using a dependency that enables gzip middleware. Is there an other workaround? |
I have the same issue and commented in #3, |
On my side, I didn't want to change the gzip configuration. So I ended up by manually creating the route required. Here is a piece of code for others that don't want to change the gzip config as well: import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/swaggo/files"
)
type Endpoint struct {
}
func (e *Endpoint) RegisterRoutes(g *echo.Group) {
g.GET("/favicon-16x16.png", func(c echo.Context) error {
return c.Blob(http.StatusOK, "image/png", swaggerFiles.FileFavicon16x16Png)
})
g.GET("/favicon-32x32.png", func(c echo.Context) error {
return c.Blob(http.StatusOK, "image/png", swaggerFiles.FileFavicon32x32Png)
})
g.GET("/swagger-ui.css", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/css", swaggerFiles.FileSwaggerUICSS)
})
g.GET("/swagger-ui.css.map", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/css", swaggerFiles.FileSwaggerUICSSMap)
})
g.GET("/index.html", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/html; charset=UTF-8", []byte(indexTempl))
})
g.GET("/doc.json", func(c echo.Context) error {
return c.Blob(http.StatusOK, "application/json; charset=UTF-8", []byte(docAPI.Swagger))
})
g.GET("/swagger-ui.js", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/javascript", swaggerFiles.FileSwaggerUIJs)
})
g.GET("/swagger-ui.js.map", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/javascript", swaggerFiles.FileSwaggerUIJsMap)
})
g.GET("/swagger-ui-bundle.js", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/javascript", swaggerFiles.FileSwaggerUIBundleJs)
})
g.GET("/swagger-ui-bundle.js.map", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/javascript", swaggerFiles.FileSwaggerUIBundleJsMap)
})
g.GET("/swagger-ui-standalone-preset.js", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/javascript", swaggerFiles.FileSwaggerUIStandalonePresetJs)
})
g.GET("/swagger-ui-standalone-preset.js.map", func(c echo.Context) error {
return c.Blob(http.StatusOK, "text/javascript", swaggerFiles.FileSwaggerUIStandalonePresetJsMap)
})
} |
This seems with gzip middleware somehow flush does not work, so manually doing flush works OK. |
Added the solution to problem with blank page when using gzip to documents for better visibility GH-19
I use gzip middleware as it is needed for faster througput, but on using it swagger doesnt work.
The text was updated successfully, but these errors were encountered: