mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-15 06:22:50 +00:00
Build Media Proxy
This commit is contained in:
parent
16bf825e14
commit
a1e57d874f
6 changed files with 142 additions and 34 deletions
14
src/proxy.rs
14
src/proxy.rs
|
@ -0,0 +1,14 @@
|
|||
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!("Proxy: ", &url);
|
||||
let client = Client::default();
|
||||
client.get(url)
|
||||
.send()
|
||||
.await
|
||||
.map_err(Error::from)
|
||||
.and_then(|res| {
|
||||
Ok(HttpResponse::build(res.status()).streaming(res))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue