adding cache header
This commit is contained in:
parent
2f5d8764b6
commit
3d00a5c888
1 changed files with 3 additions and 2 deletions
|
@ -6,6 +6,7 @@ use axum::{
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
};
|
};
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
|
use reqwest::header;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio_stream::Stream;
|
use tokio_stream::Stream;
|
||||||
use tokio_util::bytes::Bytes;
|
use tokio_util::bytes::Bytes;
|
||||||
|
@ -19,7 +20,7 @@ pub async fn handle_secure(
|
||||||
let decrypt = crypt::decryt(data, state.secret_key.clone().unwrap())?;
|
let decrypt = crypt::decryt(data, state.secret_key.clone().unwrap())?;
|
||||||
|
|
||||||
let bytes = handle(decrypt, state).await?;
|
let bytes = handle(decrypt, state).await?;
|
||||||
Ok(axum::body::Body::from_stream(bytes))
|
Ok(([(header::CACHE_CONTROL, "public, max-age=31919000")], axum::body::Body::from_stream(bytes)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_unsecure(
|
pub async fn handle_unsecure(
|
||||||
|
@ -28,7 +29,7 @@ pub async fn handle_unsecure(
|
||||||
) -> Result<impl IntoResponse, MyAnyhow> {
|
) -> Result<impl IntoResponse, MyAnyhow> {
|
||||||
let bytes = handle(src, state).await?;
|
let bytes = handle(src, state).await?;
|
||||||
|
|
||||||
Ok(axum::body::Body::from_stream(bytes))
|
Ok(([(header::CACHE_CONTROL, "public, max-age=31919000")], axum::body::Body::from_stream(bytes)))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle(
|
async fn handle(
|
||||||
|
|
Loading…
Reference in a new issue