cleanups
This commit is contained in:
50
Software/MainBoard/rust/src/webserver/get_static.rs
Normal file
50
Software/MainBoard/rust/src/webserver/get_static.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use crate::fat_error::FatError;
|
||||
use edge_http::io::server::Connection;
|
||||
use embedded_io_async::{Read, Write};
|
||||
|
||||
pub(crate) async fn serve_favicon<T, const N: usize>(
|
||||
conn: &mut Connection<'_, T, { N }>,
|
||||
) -> Result<Option<u32>, FatError>
|
||||
where
|
||||
T: Read + Write,
|
||||
{
|
||||
conn.initiate_response(200, Some("OK"), &[("Content-Type", "image/x-icon")])
|
||||
.await?;
|
||||
conn.write_all(include_bytes!("favicon.ico")).await?;
|
||||
Ok(Some(200))
|
||||
}
|
||||
|
||||
pub(crate) async fn serve_index<T, const N: usize>(
|
||||
conn: &mut Connection<'_, T, { N }>,
|
||||
) -> Result<Option<u32>, FatError>
|
||||
where
|
||||
T: Read + Write,
|
||||
{
|
||||
conn.initiate_response(
|
||||
200,
|
||||
Some("OK"),
|
||||
&[("Content-Type", "text/html"), ("Content-Encoding", "gzip")],
|
||||
)
|
||||
.await?;
|
||||
conn.write_all(include_bytes!("index.html.gz")).await?;
|
||||
Ok(Some(200))
|
||||
}
|
||||
|
||||
pub(crate) async fn serve_bundle<T, const N: usize>(
|
||||
conn: &mut Connection<'_, T, { N }>,
|
||||
) -> Result<Option<u32>, FatError>
|
||||
where
|
||||
T: Read + Write,
|
||||
{
|
||||
conn.initiate_response(
|
||||
200,
|
||||
Some("OK"),
|
||||
&[
|
||||
("Content-Type", "text/javascript"),
|
||||
("Content-Encoding", "gzip"),
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
conn.write_all(include_bytes!("bundle.js.gz")).await?;
|
||||
Ok(Some(200))
|
||||
}
|
||||
Reference in New Issue
Block a user