Compress
少于1分钟
Compress
Compression middleware for Fiber that will compress the response using gzip
, deflate
and brotli
compression depending on the Accept-Encoding header.
用于 Fiber 的压缩中间件,它将使用 gzip
、 deflate
和 brotli
压缩来压缩响应,具体取决于 Accept-Encoding 标头。
NOTE 注意
The compression middleware refrains from compressing bodies that are smaller than 200 bytes. This decision is based on the observation that, in such cases, the compressed size is likely to exceed the original size, making compression inefficient. more
压缩中间件不会压缩小于 200 字节的主体。此决定基于以下观察:在这种情况下,压缩后的尺寸很可能超过原始尺寸,从而使压缩效率低下。更多
Signatures 签名
|
|
Examples 示例
Import the middleware package that is part of the Fiber web framework
导入 Fiber Web 框架的一部分中间件包
|
|
After you initiate your Fiber app, you can use the following possibilities:
在启动 Fiber 应用后,您可以使用以下可能性:
|
|
Config 配置
Config 配置
Property 属性 | Type 输入 | Description 说明 | Default 默认 |
---|---|---|---|
Next 下一步 | func(*fiber.Ctx) bool | Next defines a function to skip this middleware when returned true. 接下来定义一个函数,在返回 true 时跳过此中间件。 | nil |
Level 级别 | Level | Level determines the compression algorithm. 级别确定压缩算法。 | LevelDefault (0) |
Possible values for the “Level” field are:
“级别”字段的可能值为:
LevelDisabled (-1)
: Compression is disabled.LevelDisabled (-1)
:禁用压缩。LevelDefault (0)
: Default compression level.LevelDefault (0)
:默认压缩级别。LevelBestSpeed (1)
: Best compression speed.LevelBestSpeed (1)
:最佳压缩速度。LevelBestCompression (2)
: Best compression.LevelBestCompression (2)
:最佳压缩。
Default Config 默认配置
|
|
Constants 常量
|
|