1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-01 22:51:17 +02:00

Defaults for middleware config

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-03-31 16:30:19 -07:00
parent 1b3197a149
commit 1113413441
5 changed files with 39 additions and 8 deletions

View File

@@ -13,9 +13,10 @@ import (
)
type (
// GzipConfig defines config for gzip middleware.
// GzipConfig defines the config for gzip middleware.
GzipConfig struct {
// Level is the gzip level.
// Optional with default value as `DefaultGzipConfig.Level`.
Level int
}
@@ -41,6 +42,11 @@ func Gzip() echo.MiddlewareFunc {
// GzipFromConfig return gzip middleware from config.
// See `Gzip()`.
func GzipFromConfig(config GzipConfig) echo.MiddlewareFunc {
// Defaults
if config.Level == 0 {
config.Level = DefaultGzipConfig.Level
}
pool := gzipPool(config)
scheme := "gzip"