opti htmx in release mode
This commit is contained in:
parent
75d280f928
commit
c0402e0dca
@ -1,11 +1,11 @@
|
|||||||
|
use core::fmt::Write;
|
||||||
use core::str::from_utf8;
|
use core::str::from_utf8;
|
||||||
use embassy_net::tcp::TcpSocket;
|
use embassy_net::tcp::TcpSocket;
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
|
use embedded_io_async::Write as _;
|
||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use pico_website::unwrap;
|
use pico_website::unwrap;
|
||||||
use embedded_io_async::Write as _;
|
|
||||||
use core::fmt::Write;
|
|
||||||
|
|
||||||
use crate::game::{GameClient, Team};
|
use crate::game::{GameClient, Team};
|
||||||
|
|
||||||
@ -96,27 +96,24 @@ pub async fn listen_task(stack: embassy_net::Stack<'static>, team: Team, port: u
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
info!(
|
info!("Socket {:?}: {:?} request for {}", team, request_type, path);
|
||||||
"Socket {:?}: {:?} request for {}",
|
|
||||||
team,
|
|
||||||
request_type,
|
|
||||||
path
|
|
||||||
);
|
|
||||||
Timer::after_secs(0).await;
|
Timer::after_secs(0).await;
|
||||||
|
|
||||||
let (code, res_type, res_content): (HttpResCode, &str, &[u8]) = match path {
|
let (code, res_type, res_content): (HttpResCode, &str, &[u8]) = match path {
|
||||||
"/" => (HttpResCode::Ok, "html", include_bytes!("../static/index.html")),
|
"/" => (
|
||||||
"/htmx.min.js" => (
|
|
||||||
HttpResCode::Ok,
|
HttpResCode::Ok,
|
||||||
"javascript",
|
"html",
|
||||||
include_bytes!("../static/htmx.min.js"),
|
include_bytes!("../static/index.html"),
|
||||||
),
|
),
|
||||||
"/htmx.js" => (
|
"/htmx.js" => (
|
||||||
HttpResCode::Ok,
|
HttpResCode::Ok,
|
||||||
"javascript",
|
"javascript",
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
include_bytes!("../static/htmx.js"),
|
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();
|
res_head_buf.clear();
|
||||||
@ -160,7 +157,7 @@ impl Into<&str> for HttpRequestType {
|
|||||||
fn into(self) -> &'static str {
|
fn into(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Get => "GET",
|
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",
|
HttpResCode::Forbidden => "HTTP/1.1 403 FORBIDDEN",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user