This commit is contained in:
lda
2026-01-19 01:10:56 +07:00 Unverified
parent 51888b7a8e
commit 70b4e59f28
5 changed files with 3 additions and 78 deletions
-31
View File
@@ -1,31 +0,0 @@
// generated with ./scripts/map_static.py
macro_rules! hehe {
// Folder
(folder $name:ident { $($children:tt)* } $($rest:tt)*) => {
pub mod $name {
hehe!{$($children)*}
}
hehe!{$($rest)*}
};
// File
(file $name:ident $file:literal $($rest:tt)*) => {
pub const $name: &str = include_str!($file);
hehe!{$($rest)*}
};
// Base case
() => {};
}
hehe! {
file HOME_2_HTML "../static/index.html"
folder home_2 {
file DOM_JS "../static/home_2/dom.js"
file LEASES_JS "../static/home_2/leases.js"
file MAIN_JS "../static/home_2/main.js"
file STATUS_JS "../static/home_2/status.js"
file STYLES_CSS "../static/home_2/styles.css"
file UTILS_JS "../static/home_2/utils.js"
file WAKE_JS "../static/home_2/wake.js"
}
}
-1
View File
@@ -11,7 +11,6 @@
use axum::Router; use axum::Router;
use tokio::net::TcpListener; use tokio::net::TcpListener;
mod arpparse; mod arpparse;
pub mod assets;
mod dhcpparse; mod dhcpparse;
mod route; mod route;
mod utils; mod utils;
+3 -34
View File
@@ -5,7 +5,7 @@ pub mod error;
pub mod status; pub mod status;
pub mod wake; pub mod wake;
use crate::assets; // use crate::assets;
use crate::dhcpparse::load_mac_name_cache; use crate::dhcpparse::load_mac_name_cache;
use crate::route::api::ip; use crate::route::api::ip;
use crate::route::api::status_redirect; use crate::route::api::status_redirect;
@@ -18,43 +18,12 @@ use crate::route::wake::wake_multi;
use axum::Json; use axum::Json;
use axum::Router; use axum::Router;
use axum::body::Body; use axum::body::Body;
use axum::http::{Request, header}; use axum::http::Request;
use axum::middleware::{self, Next}; use axum::middleware::{self, Next};
use axum::response::{Html, IntoResponse, Response}; use axum::response::{IntoResponse, Response};
use axum::routing::{get, post}; use axum::routing::{get, post};
use std::time::Instant; use std::time::Instant;
use crate::utils::route::serve_js;
pub async fn home_2() -> Html<&'static str> {
Html(assets::HOME_2_HTML)
}
pub fn home_2_route() -> Router {
use assets::*;
Router::new()
.route("/home_2", get(|| async { Html(HOME_2_HTML) }))
.route("/home_2/", get(|| async { Html(HOME_2_HTML) }))
.route("/home_2.html", get(|| async { Html(HOME_2_HTML) }))
.route(
"/home_2/styles.css",
get(|| async {
(
[
(header::CONTENT_TYPE, "text/css; charset=utf-8"),
(header::CACHE_CONTROL, "public, max-age=300"),
],
home_2::STYLES_CSS,
)
}),
)
.route("/home_2/main.js", get(|| serve_js(home_2::MAIN_JS)))
.route("/home_2/leases.js", get(|| serve_js(home_2::LEASES_JS)))
.route("/home_2/status.js", get(|| serve_js(home_2::STATUS_JS)))
.route("/home_2/utils.js", get(|| serve_js(home_2::UTILS_JS)))
.route("/home_2/wake.js", get(|| serve_js(home_2::WAKE_JS)))
.route("/home_2/dom.js", get(|| serve_js(home_2::DOM_JS)))
}
async fn add_performance_header(req: Request<Body>, next: Next) -> Response { async fn add_performance_header(req: Request<Body>, next: Next) -> Response {
let start = Instant::now(); let start = Instant::now();
let mut response = next.run(req).await; let mut response = next.run(req).await;
-1
View File
@@ -13,7 +13,6 @@ pub mod wake;
// this is so bad // this is so bad
pub mod ping; pub mod ping;
pub mod query; pub mod query;
pub mod route;
// no custom ip deserializer needed when using axum_extra::extract::Query // no custom ip deserializer needed when using axum_extra::extract::Query
// but we add a generic one to ignore blanks and accept OneOrMany // but we add a generic one to ignore blanks and accept OneOrMany
-11
View File
@@ -1,11 +0,0 @@
use axum::{http::header, response::IntoResponse};
pub async fn serve_js(content: &'static str) -> impl IntoResponse {
(
[
(header::CONTENT_TYPE, "application/javascript"),
(header::CACHE_CONTROL, "public, max-age=300"),
],
content,
)
}