rocket hello world stuff
This commit is contained in:
parent
7f0ad405b8
commit
6b9b5eff1d
1552
Cargo.lock
generated
1552
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -5,4 +5,5 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
atom_syndication = "0.12.6"
|
atom_syndication = "0.12.6"
|
||||||
|
rocket = { version = "0.5.1", features = ["json"] }
|
||||||
rss = "2.0.11"
|
rss = "2.0.11"
|
||||||
|
32
src/main.rs
32
src/main.rs
@ -1,3 +1,31 @@
|
|||||||
fn main() {
|
#[macro_use] extern crate rocket;
|
||||||
println!("Hello, world!");
|
|
||||||
|
use rocket::serde::{Serialize, json::Json};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(crate = "rocket::serde")]
|
||||||
|
struct Message {
|
||||||
|
a: i32,
|
||||||
|
b: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/message")]
|
||||||
|
fn message() -> Json<Message> {
|
||||||
|
Json(Message {
|
||||||
|
a: -4,
|
||||||
|
b: "Hallo".to_string()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
fn index() -> &'static str {
|
||||||
|
"yolo swagg"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[launch]
|
||||||
|
fn rocket() -> _ {
|
||||||
|
rocket::build().mount("/", routes![index, message])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user