bskyweb: config gzip to skip some files

This commit is contained in:
bryan newbold
2023-05-31 19:15:38 -07:00
parent 6fd4101eaa
commit fa19e9ebe7
+13 -2
View File
@@ -101,8 +101,19 @@ func serve(cctx *cli.Context) error {
RedirectCode: http.StatusFound,
}))
// enable gzip
e.Use(middleware.Gzip())
// gzip transport compression for most responses.
// echo middleware is pretty naive, defaults to compressing every response,
// of any mimetype or size. we configure to skip some cases, but this is a
// pretty incomplete set of patterns.
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
Skipper: func(c echo.Context) bool {
// don't compress PNG files, specifically
return strings.HasSuffix(c.Request().URL.Path, ".png")
},
Level: -1, // default
// TODO: https://github.com/labstack/echo/pull/2267
//MinLength: 1024, // default is "0"
}))
//
// configure routes