pico-website/src/apps/index.rs
2025-05-02 00:37:11 +02:00

24 lines
590 B
Rust

use crate::socket::{HttpRequestType, HttpResCode};
use super::App;
pub struct IndexApp;
impl App for IndexApp {
fn socket_name(&self) -> &'static str {
"index"
}
async fn handle_request<'a>(
&'a mut self,
path: &str,
_req_type: HttpRequestType,
_content: &str,
) -> (HttpResCode, &'static str, &'a [u8]) {
match path {
"/" | "/index" | "/index.html" => {
(HttpResCode::Ok, "html", include_bytes!("./index.html"))
}
_ => (HttpResCode::NotFound, "", &[]),
}
}
}