From c0402e0dca66758f40d876df44dcd2cd872f8ea7 Mon Sep 17 00:00:00 2001 From: Arkitu <85173315+Arkitu@users.noreply.github.com> Date: Sat, 26 Apr 2025 22:51:27 +0200 Subject: [PATCH] opti htmx in release mode --- src/socket.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/socket.rs b/src/socket.rs index 3075a7f..38d923d 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -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", } } -} \ No newline at end of file +}