51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
use crate::fat_error::FatError;
|
|
use edge_http::io::server::Connection;
|
|
use edge_nal::io::{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))
|
|
}
|