Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
/ carriage Public archive

Prototype of a simple web server inspired from nodejs express.

Notifications You must be signed in to change notification settings

HamzaOralK/carriage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Carriage

Carriage is a Rust framework for web applications and API that I have developed to learn rust on the way.

Usage

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut router = Router::new("my route");
    let mut cr = carriage::Carriage::new("127.0.0.1", "7878", &mut router);
    let test_route: Route = Route::new(Method::GET, "/users", test1);
    let test_route2: Route = Route::new(Method::GET, "/products", test2);
    cr.router.add_route(test_route);
    cr.router.add_route(test_route2);
    cr.connect();
}

fn test1(req: Request) -> Response<'static> {
    let body = req.body;
    if body.data["productId"] == "test" {
    }
    let res = Response { code: HttpCodes::Ok, body: "asdasd"};
    res
}

Usage

To run cargo run, to build cargo build --release.

License

MIT

About

Prototype of a simple web server inspired from nodejs express.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages