2 releases

0.1.3 Feb 4, 2023
0.1.2 Feb 4, 2023
0.1.1 Feb 4, 2023
0.1.0 Feb 4, 2023

#821 in HTTP server

Download history 6/week @ 2024-02-26 1/week @ 2024-03-11 68/week @ 2024-04-01

69 downloads per month

MIT license

7KB
83 lines

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();
}

The module that contains all the handler structs The module that contains all the types and type aliases

Dependencies

~0–8.5MB
~53K SLoC