How to use rocket crate in Rust web framework

Add the rocket crate to Cargo.toml and launch the server using rocket::ignite() with the routes! macro to define endpoints.

Add the rocket crate to your Cargo.toml and initialize the server using rocket::ignite() with route definitions via the routes! macro.

use rocket::Route;

#[rocket::get("/")]
fn index() -> &'static str {
    "Hello, world!"
}

fn main() {
    rocket::ignite()
        .mount("/", routes![index])
        .launch();
}