Cache robots.txt
This commit is contained in:
parent
0f506fc41b
commit
b33d79ed9b
@ -16,7 +16,9 @@ async fn style() -> HttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn robots() -> HttpResponse {
|
async fn robots() -> HttpResponse {
|
||||||
HttpResponse::Ok().body(include_str!("../static/robots.txt"))
|
HttpResponse::Ok()
|
||||||
|
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400")
|
||||||
|
.body(include_str!("../static/robots.txt"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/favicon.ico")]
|
#[get("/favicon.ico")]
|
||||||
|
11
src/proxy.rs
11
src/proxy.rs
@ -28,18 +28,13 @@ pub async fn handler(web::Path(b64): web::Path<String>) -> Result<HttpResponse>
|
|||||||
let domain = url.domain().unwrap_or_default();
|
let domain = url.domain().unwrap_or_default();
|
||||||
|
|
||||||
if domains.contains(&domain) {
|
if domains.contains(&domain) {
|
||||||
Client::default()
|
Client::default().get(media.replace("&", "&")).send().await.map_err(Error::from).map(|res| {
|
||||||
.get(media.replace("&", "&"))
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
.map_err(Error::from)
|
|
||||||
.map(|res|
|
|
||||||
HttpResponse::build(res.status())
|
HttpResponse::build(res.status())
|
||||||
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400, must-revalidate")
|
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400")
|
||||||
.header("Content-Length", res.headers().get("Content-Length").unwrap().to_owned())
|
.header("Content-Length", res.headers().get("Content-Length").unwrap().to_owned())
|
||||||
.header("Content-Type", res.headers().get("Content-Type").unwrap().to_owned())
|
.header("Content-Type", res.headers().get("Content-Type").unwrap().to_owned())
|
||||||
.streaming(res)
|
.streaming(res)
|
||||||
)
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(error::ErrorForbidden("Resource must be from Reddit"))
|
Err(error::ErrorForbidden("Resource must be from Reddit"))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user