mirror of
https://github.com/TeamPiped/piped-proxy.git
synced 2024-08-14 23:50:45 +00:00
Turn webp rewriting into a feature flag.
This commit is contained in:
parent
53329c43e8
commit
5212b4213c
2 changed files with 10 additions and 5 deletions
|
@ -8,7 +8,7 @@ version = "0.1.0"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.3.1"
|
actix-web = "4.3.1"
|
||||||
image = "0.24.6"
|
image = "0.24.6"
|
||||||
libwebp-sys = "0.9.2"
|
libwebp-sys = { version = "0.9.2", optional = true }
|
||||||
mimalloc = "0.1.37"
|
mimalloc = "0.1.37"
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
qstring = "0.7.2"
|
qstring = "0.7.2"
|
||||||
|
@ -19,4 +19,6 @@ reqwest = { version = "0.11.18", features = ["rustls-tls", "stream", "brotli", "
|
||||||
tokio = { version = "1.29.1", features = ["full"] }
|
tokio = { version = "1.29.1", features = ["full"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = ["webp"]
|
||||||
avif = ["dep:ravif", "dep:rgb"]
|
avif = ["dep:ravif", "dep:rgb"]
|
||||||
|
webp = ["dep:libwebp-sys"]
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
|
use actix_web::{App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer, web};
|
||||||
use actix_web::http::Method;
|
use actix_web::http::Method;
|
||||||
use actix_web::{web, App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer};
|
|
||||||
use libwebp_sys::{WebPEncodeRGB, WebPFree};
|
|
||||||
use mimalloc::MiMalloc;
|
use mimalloc::MiMalloc;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use qstring::QString;
|
use qstring::QString;
|
||||||
|
@ -221,7 +220,10 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "webp")]
|
||||||
if content_type == "image/jpeg" {
|
if content_type == "image/jpeg" {
|
||||||
|
use libwebp_sys::{WebPEncodeRGB, WebPFree};
|
||||||
|
|
||||||
let resp_bytes = resp.bytes().await.unwrap();
|
let resp_bytes = resp.bytes().await.unwrap();
|
||||||
|
|
||||||
let image = image::load_from_memory(&resp_bytes).unwrap();
|
let image = image::load_from_memory(&resp_bytes).unwrap();
|
||||||
|
@ -256,6 +258,7 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
|
||||||
response.content_type("image/jpeg");
|
response.content_type("image/jpeg");
|
||||||
return Ok(response.body(resp_bytes));
|
return Ok(response.body(resp_bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
if content_type == "application/x-mpegurl"
|
if content_type == "application/x-mpegurl"
|
||||||
|| content_type == "application/vnd.apple.mpegurl"
|
|| content_type == "application/vnd.apple.mpegurl"
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue