v0.13.8
This commit is contained in:
@@ -50,6 +50,7 @@ const INDEX_HTML: &str = include_str!("../web/index.html");
|
||||
const NOT_FOUND_HTML: &str = include_str!("../web/404.html");
|
||||
const APP_JS: &str = include_str!(concat!(env!("OUT_DIR"), "/app.bundle.js"));
|
||||
const THEME_INIT_JS: &str = include_str!("../web/theme-init.js");
|
||||
const LANG_INIT_JS: &str = include_str!("../web/lang-init.js");
|
||||
const STYLES_CSS: &str = include_str!("../web/styles.css");
|
||||
const MANIFEST: &str = include_str!("../web/manifest.webmanifest");
|
||||
const SERVICE_WORKER: &str = include_str!("../web/sw.js");
|
||||
@@ -257,6 +258,7 @@ pub fn router(state: AppState) -> Router {
|
||||
.route("/index.html", get(index))
|
||||
.route(APP_JS_ASSET_PATH, get(app_js))
|
||||
.route(THEME_INIT_ASSET_PATH, get(theme_init_js))
|
||||
.route(LANG_INIT_ASSET_PATH, get(lang_init_js))
|
||||
.route(STYLES_CSS_ASSET_PATH, get(styles_css))
|
||||
.route("/manifest.webmanifest", get(manifest))
|
||||
.route("/sw.js", get(service_worker))
|
||||
|
||||
+13
-1
@@ -38,6 +38,10 @@ async fn index(State(state): State<AppState>, headers: HeaderMap) -> Response {
|
||||
"__GREE_THEME_INIT_ASSET__",
|
||||
&format!("{base}{THEME_INIT_ASSET_PATH}"),
|
||||
)
|
||||
.replace(
|
||||
"__GREE_LANG_INIT_ASSET__",
|
||||
&format!("{base}{LANG_INIT_ASSET_PATH}"),
|
||||
)
|
||||
.replace(
|
||||
"__GREE_STYLES_ASSET__",
|
||||
&format!("{base}{STYLES_CSS_ASSET_PATH}"),
|
||||
@@ -95,6 +99,13 @@ async fn theme_init_js() -> Response {
|
||||
"public, max-age=31536000, immutable",
|
||||
)
|
||||
}
|
||||
async fn lang_init_js() -> Response {
|
||||
static_response(
|
||||
LANG_INIT_JS,
|
||||
"application/javascript; charset=utf-8",
|
||||
"public, max-age=31536000, immutable",
|
||||
)
|
||||
}
|
||||
async fn styles_css() -> Response {
|
||||
static_response(
|
||||
STYLES_CSS,
|
||||
@@ -114,6 +125,7 @@ async fn service_worker() -> Response {
|
||||
.replace("__GREE_ASSET_CACHE__", ASSET_BUILD_ID)
|
||||
.replace("__GREE_APP_ASSET__", APP_JS_ASSET_PATH)
|
||||
.replace("__GREE_THEME_INIT_ASSET__", THEME_INIT_ASSET_PATH)
|
||||
.replace("__GREE_LANG_INIT_ASSET__", LANG_INIT_ASSET_PATH)
|
||||
.replace("__GREE_STYLES_ASSET__", STYLES_CSS_ASSET_PATH);
|
||||
owned_response(body, "application/javascript; charset=utf-8", "no-cache")
|
||||
}
|
||||
@@ -133,7 +145,7 @@ async fn language_file(Path(file): Path<String>) -> Response {
|
||||
.iter()
|
||||
.find(|(language, _)| *language == code)
|
||||
{
|
||||
return static_response(*body, "application/json; charset=utf-8", "no-cache");
|
||||
return static_response(*body, "application/json; charset=utf-8", "public, max-age=31536000, immutable");
|
||||
}
|
||||
let mut response = Response::new(Body::from("Language not found"));
|
||||
*response.status_mut() = StatusCode::NOT_FOUND;
|
||||
|
||||
Reference in New Issue
Block a user