rama_http/layer/decompression/request/
layer.rs1use super::service::RequestDecompression;
2use crate::headers::encoding::AcceptEncoding;
3use rama_core::Layer;
4
5#[derive(Debug, Default, Clone)]
17pub struct RequestDecompressionLayer {
18 accept: AcceptEncoding,
19 pass_through_unaccepted: bool,
20}
21
22impl<S> Layer<S> for RequestDecompressionLayer {
23 type Service = RequestDecompression<S>;
24
25 fn layer(&self, service: S) -> Self::Service {
26 RequestDecompression {
27 inner: service,
28 accept: self.accept,
29 pass_through_unaccepted: self.pass_through_unaccepted,
30 }
31 }
32}
33
34impl RequestDecompressionLayer {
35 pub fn new() -> Self {
37 Default::default()
38 }
39
40 pub fn gzip(mut self, enable: bool) -> Self {
42 self.accept.set_gzip(enable);
43 self
44 }
45
46 pub fn set_gzip(&mut self, enable: bool) -> &mut Self {
48 self.accept.set_gzip(enable);
49 self
50 }
51
52 pub fn deflate(mut self, enable: bool) -> Self {
54 self.accept.set_deflate(enable);
55 self
56 }
57
58 pub fn set_deflate(&mut self, enable: bool) -> &mut Self {
60 self.accept.set_deflate(enable);
61 self
62 }
63
64 pub fn br(mut self, enable: bool) -> Self {
66 self.accept.set_br(enable);
67 self
68 }
69
70 pub fn set_br(&mut self, enable: bool) -> &mut Self {
72 self.accept.set_br(enable);
73 self
74 }
75
76 pub fn zstd(mut self, enable: bool) -> Self {
78 self.accept.set_zstd(enable);
79 self
80 }
81
82 pub fn set_zstd(&mut self, enable: bool) -> &mut Self {
84 self.accept.set_zstd(enable);
85 self
86 }
87
88 pub fn pass_through_unaccepted(mut self, enable: bool) -> Self {
90 self.pass_through_unaccepted = enable;
91 self
92 }
93
94 pub fn set_pass_through_unaccepted(&mut self, enable: bool) -> &mut Self {
96 self.pass_through_unaccepted = enable;
97 self
98 }
99}