mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
misc: improve default compress function
This commit is contained in:
parent
e9a1aeebce
commit
a3ec0ccf99
@ -12,6 +12,7 @@ use actix_http::encoding::Encoder;
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_utils::future::{ok, Either, Ready};
|
||||
use futures_core::ready;
|
||||
use mime::Mime;
|
||||
use once_cell::sync::Lazy;
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
@ -86,7 +87,16 @@ impl fmt::Debug for Compress {
|
||||
impl Default for Compress {
|
||||
fn default() -> Self {
|
||||
Compress {
|
||||
compress: |_| false,
|
||||
compress: |content_type| match content_type {
|
||||
None => true,
|
||||
Some(value) => {
|
||||
let response_mime: Mime = value.to_str().unwrap().parse::<Mime>().unwrap();
|
||||
match response_mime.type_().as_str() {
|
||||
"image" => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user