actix / actix/actix-web

Allow setting compression levels

未关闭
#2,928 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
A-http A-web C-improvement
主要语言
Rust
星标
24.8k
派生
1.9k
平均合并
23 小时 10 分钟
30 天内合并 PR
26

描述

## Expected Behavior

Although the default compression levels are sane, some users might want to adjust it to better fit their needs. Being able to set the compression levels gives users more control and flexibility.

## Current Behavior

```rust
.wrap(Compress::default())
```

That's super easy to add, but there are no ways to fine-tune the compression algos.

## Possible Solution

I like the defaults, although the available compression algos aren't that transparent, in a sense that it's tricky to figure out which ones are going to be supported from looking at the init code alone. I think that keeping it that way is fine, but it would be nice to have an alternative way to configure compression, here is a pseudo-code:

```rust
.wrap(Compress::setup(
vec![
Gzip::Level_5,
Brotli::Level_7,
]
))
```

I'm relatively new to Rust, so take it with a grain of salt, I'm sure there are some more convenient/idiomatic patterns which can be used to setup the compression levels.

## Context

I'm fine with the current defaults but I have some spare CPU capacity so it wouldn't hurt to keep it busy. Also, I'm planning to add Tor support to one of the APIs I'm working on, so optimizing for bandwidth would certainly help to speed things up a bit.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。