Expand description
a crate for making a customizable http web server, similar to express from node.js or bao from bun.js
example:
use haws::handlers::{ AppHandler };
use haws::types::{ RequestBuffer };
fn main() {
fn index(_buffer: RequestBuffer) -> String {
return "<h1>Hello world</h1>".to_string();
}
fn err_page(_buffer: RequestBuffer) -> String {
return "<h1>404 page not found</h1>".to_string();
}
let mut app = AppHandler::new("localhost".to_string(), 3000);
// if you put a '/' in the path paramater then every time the client navigates to the root of the page or just "localhost:3000" not "localhost:3000/home" or anything like that just the root no extra path after "localhost:3000", once you navigate to this route it will return the html in the dest attribute
app.route("/".to_string(), &index);
// if you put a '.' in the path paramater then every time the client navigates to a route that doesn't exist it will return the html in the dest attribute
app.route(".".to_string(), &err_page);
app.serve();
}