mirror of
https://github.com/spikecodes/libreddit.git
synced 2026-01-20 11:42:33 +01:00
Make Proxy Optional Feature
This commit is contained in:
22
src/proxy.rs
22
src/proxy.rs
@@ -2,13 +2,17 @@ use actix_web::{get, web, HttpResponse, Result, client::Client, Error};
|
||||
|
||||
#[get("/imageproxy/{url:.*}")]
|
||||
async fn handler(web::Path(url): web::Path<String>) -> Result<HttpResponse> {
|
||||
dbg!(&url);
|
||||
let client = Client::default();
|
||||
client.get(url)
|
||||
.send()
|
||||
.await
|
||||
.map_err(Error::from)
|
||||
.and_then(|res| {
|
||||
Ok(HttpResponse::build(res.status()).streaming(res))
|
||||
})
|
||||
if cfg!(feature = "proxy") {
|
||||
dbg!(&url);
|
||||
let client = Client::default();
|
||||
client.get(url)
|
||||
.send()
|
||||
.await
|
||||
.map_err(Error::from)
|
||||
.and_then(|res| {
|
||||
Ok(HttpResponse::build(res.status()).streaming(res))
|
||||
})
|
||||
} else {
|
||||
Ok(HttpResponse::Ok().body(""))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user