opti htmx in release mode

This commit is contained in:
Arkitu 2025-04-26 22:51:27 +02:00
parent 75d280f928
commit c0402e0dca

View File

@ -1,11 +1,11 @@
use core::fmt::Write;
use core::str::from_utf8;
use embassy_net::tcp::TcpSocket;
use embassy_time::{Duration, Timer};
use embedded_io_async::Write as _;
use heapless::Vec;
use log::{info, warn};
use pico_website::unwrap;
use embedded_io_async::Write as _;
use core::fmt::Write;
use crate::game::{GameClient, Team};
@ -96,27 +96,24 @@ pub async fn listen_task(stack: embassy_net::Stack<'static>, team: Team, port: u
}
};
info!(
"Socket {:?}: {:?} request for {}",
team,
request_type,
path
);
info!("Socket {:?}: {:?} request for {}", team, request_type, path);
Timer::after_secs(0).await;
let (code, res_type, res_content): (HttpResCode, &str, &[u8]) = match path {
"/" => (HttpResCode::Ok, "html", include_bytes!("../static/index.html")),
"/htmx.min.js" => (
"/" => (
HttpResCode::Ok,
"javascript",
include_bytes!("../static/htmx.min.js"),
"html",
include_bytes!("../static/index.html"),
),
"/htmx.js" => (
HttpResCode::Ok,
"javascript",
#[cfg(debug_assertions)]
include_bytes!("../static/htmx.js"),
#[cfg(not(debug_assertions))]
include_bytes!("../static/htmx.min.js"),
),
p => game_client.handle_request(p).await
p => game_client.handle_request(p).await,
};
res_head_buf.clear();
@ -160,7 +157,7 @@ impl Into<&str> for HttpRequestType {
fn into(self) -> &'static str {
match self {
Self::Get => "GET",
Self::Post => "POST"
Self::Post => "POST",
}
}
}
@ -181,4 +178,4 @@ impl Into<&str> for HttpResCode {
HttpResCode::Forbidden => "HTTP/1.1 403 FORBIDDEN",
}
}
}
}