mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 02:47:45 +08:00
feat: support admin online update and deploy flow
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use axum::extract::Request;
|
||||
use axum::http::Method;
|
||||
use axum::http::header::{CACHE_CONTROL, EXPIRES, PRAGMA};
|
||||
use axum::http::{HeaderValue, Method};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::routing::any;
|
||||
use axum::Router;
|
||||
@@ -112,7 +113,16 @@ async fn serve_static_asset(static_dir: &PathBuf, request: Request) -> Response
|
||||
|
||||
async fn serve_frontend_index(index_html: &PathBuf, request: Request) -> Response {
|
||||
match ServeFile::new(index_html).oneshot(request).await {
|
||||
Ok(response) => response.into_response(),
|
||||
Ok(mut response) => {
|
||||
let headers = response.headers_mut();
|
||||
headers.insert(
|
||||
CACHE_CONTROL,
|
||||
HeaderValue::from_static("no-store, no-cache, must-revalidate"),
|
||||
);
|
||||
headers.insert(PRAGMA, HeaderValue::from_static("no-cache"));
|
||||
headers.insert(EXPIRES, HeaderValue::from_static("0"));
|
||||
response.into_response()
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(error = %err, "failed to serve frontend index");
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR.into_response()
|
||||
|
||||
Reference in New Issue
Block a user