Skip to content

Can no longer combine with tower-http's RequestDecompression #2687

Answered by Congyuwang
tisonkun asked this question in Q&A
Discussion options

You must be logged in to vote

I just dealt with this problem. In fact with the new version, the code is greatly simplified.

First note that you have to depend on tower-http v0.5 and tower v0.4.

Next, you no longer need:

.layer(
                ServiceBuilder::new()
                    .layer(HandleErrorLayer::new(handle_error))
                    .layer(RequestDecompressionLayer::new()),
            )

instead just write something like:

.layer(RequestDecompressionLayer::new().gzip(true))

I think it's because RequestDecompressionLayer is infallible now, and so no longer needs an error handling layer. The decompression error, if any, is propagated to reading the data from the request body.

With regard to the handlers, p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tisonkun
Comment options

Answer selected by tisonkun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants