mirror of
https://github.com/labstack/echo.git
synced 2024-12-14 10:23:00 +02:00
2507dc13e9
Signed-off-by: Vishal Rana <vr@labstack.com>
49 lines
675 B
Markdown
49 lines
675 B
Markdown
+++
|
|
title = "Gzip"
|
|
[menu.side]
|
|
name = "Gzip"
|
|
parent = "middleware"
|
|
weight = 5
|
|
+++
|
|
|
|
## Gzip Middleware
|
|
|
|
Gzip middleware compresses HTTP response using gzip compression scheme.
|
|
|
|
*Usage*
|
|
|
|
`e.Use(middleware.Gzip())`
|
|
|
|
### Custom Configuration
|
|
|
|
*Usage*
|
|
|
|
```go
|
|
e := echo.New()
|
|
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
|
|
Level: 5,
|
|
}))
|
|
```
|
|
|
|
### Configuration
|
|
|
|
```go
|
|
GzipConfig struct {
|
|
// Skipper defines a function to skip middleware.
|
|
Skipper Skipper
|
|
|
|
// Gzip compression level.
|
|
// Optional. Default value -1.
|
|
Level int `json:"level"`
|
|
}
|
|
```
|
|
|
|
*Default Configuration*
|
|
|
|
```go
|
|
DefaultGzipConfig = GzipConfig{
|
|
Skipper: defaultSkipper,
|
|
Level: -1,
|
|
}
|
|
```
|