rocket_cli/templates/minimal/
files.rs1pub const CARGO_TOML: &str = r#"[package]
2name = "{{project_name}}"
3version = "0.1.0"
4edition = "2021"
5
6[dependencies]
7rocket = { version = "0.5.1", features = ["json"] }
8"#;
9
10pub const MAIN_RS: &str = r#"#[macro_use]
11extern crate rocket;
12
13mod fairings;
14mod routes;
15
16#[launch]
17fn rocket() -> _ {
18 rocket::build()
19 .attach(fairings::Cors)
20 .mount("/", routes::routes())
21}
22"#;
23
24pub const ROUTES_MOD: &str = r#"pub fn routes() -> Vec<rocket::Route> {
25 routes![index, hello]
26}
27
28#[get("/")]
29fn index() -> &'static str {
30 "Hello, {{project_name}}!"
31}
32
33/*-----------------------------------------------------------
34Rocket automatically parses dynamic data in path segments into any desired type.
35
36This hello route has two dynamic parameters, identified with angle brackets, declared in the route URI: <name> and <age>. Rocket maps each parameter to an identically named function argument: name: &str and age: u8. The dynamic data in the incoming request is parsed automatically into a value of the argument's type. The route is called only when parsing succeeds.
37
38Parsing is directed by the FromParam trait. Rocket implements FromParam for many standard types, including both &str and u8. You can implement it for your own types, too!
39-----------------------------------------------------------*/
40#[get("/hello/<name>/<age>")]
41fn hello(name: &str, age: u8) -> String {
42 format!("Hello, {} year old named {}!", age, name)
43}
44"#;