thruster-rs / Thruster

A fast, middleware based, web framework written in Rust
MIT License
1.06k stars 47 forks source link

Consuming app builder pattern #210

Closed ynuwenhof closed 2 years ago

ynuwenhof commented 2 years ago

Use the consuming builder pattern to make the construction of apps more intuitive.

New

let app = App::<Request, Ctx, ()>::new_basic().get("/plaintext", m![plaintext]);

let server = Server::new(app);
server.start("0.0.0.0", 4321);

Old

    let mut app = App::<Request, Ctx, ()>::new_basic();
    app.get("/plaintext", m![plaintext]);

    let server = Server::new(app);
    server.start("0.0.0.0", 4321);