init
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
pub mod items {
|
||||
include!(concat!(env!("OUT_DIR"), "/items.rs"));
|
||||
}
|
||||
|
||||
#[get("/<name>")]
|
||||
fn get_user(user_list: &rocket::State<Vec<items::Person>>, name: String) -> Option<items::Person> {
|
||||
user_list.iter().find(|user| user.name == name).cloned()
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index(user_list: &rocket::State<Vec<items::Person>>) -> String {
|
||||
format!("Hello, user amount: {}", user_list.len())
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
let mut user_list: Vec<items::Person> = Vec::new();
|
||||
|
||||
user_list.push(items::Person {
|
||||
name: "John".to_string(),
|
||||
opinion: vec![items::Opinion {
|
||||
game: Some(items::Game {
|
||||
title: "Naramo Nuclear Plant V2".to_string(),
|
||||
source: items::Source::Roblox.into(),
|
||||
multiplayer: true,
|
||||
min_players: 1,
|
||||
max_players: 90,
|
||||
price: 0,
|
||||
}),
|
||||
would_play: true,
|
||||
}],
|
||||
});
|
||||
|
||||
rocket::build()
|
||||
.manage(user_list)
|
||||
.mount("/", routes![index, get_user])
|
||||
}
|
||||
Reference in New Issue
Block a user