Skip to content

Commit

Permalink
Simplify compression header on AppSignal sink
Browse files Browse the repository at this point in the history
Use the `content_encoding` function to set the Content-Encoding header
value. Removes the match-statement with a simpler if-statement.
  • Loading branch information
tombruijn committed Apr 5, 2023
1 parent 1c4e189 commit 4b7b860
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/sinks/appsignal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,10 @@ impl HttpSink for AppsignalSinkConfig {
);

let mut body = crate::serde::json::to_bytes(&events)?.freeze();
let compression = self.compression;
match compression {
Compression::Gzip(_level) => {
request = request.header("Content-Encoding", "gzip");
}
Compression::Zlib(_level) => {
request = request.header("Content-Encoding", "deflate");
}
Compression::None => {}
if let Some(ce) = self.compression.content_encoding() {
request = request.header("Content-Encoding", ce);
}
let mut compressor = Compressor::from(compression);
let mut compressor = Compressor::from(self.compression);
write_all(&mut compressor, 0, &body)?;
body = compressor.finish().context(CompressionFailedSnafu)?.into();
request.body(body).map_err(Into::into)
Expand Down

0 comments on commit 4b7b860

Please sign in to comment.