First commit and models
This commit is contained in:
commit
4daf357a49
1542
Cargo.lock
generated
Normal file
1542
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "khazclock-server"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rocket = { version = "0.5.0", features = ["json"] }
|
||||||
69
src/main.rs
Normal file
69
src/main.rs
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
use rocket::serde::{json::Json, Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate rocket;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(crate = "rocket::serde")]
|
||||||
|
// struct Message {
|
||||||
|
// alarms: {
|
||||||
|
// user: i64,
|
||||||
|
// alarm: {
|
||||||
|
// id: i32,
|
||||||
|
// hour: i32,
|
||||||
|
// mins: i32,
|
||||||
|
// active: bool,
|
||||||
|
// repeat: bool,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
struct Message {
|
||||||
|
user: i32,
|
||||||
|
alarms: Vec<Alarm>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(crate = "rocket::serde")]
|
||||||
|
struct Alarm {
|
||||||
|
id: i32,
|
||||||
|
hour: i32,
|
||||||
|
mins: i32,
|
||||||
|
active: bool,
|
||||||
|
repeat: bool,
|
||||||
|
// repeat: Vec<Days>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/", format = "json")]
|
||||||
|
fn index() -> Option<Json<Message>> {
|
||||||
|
Some(Json(Message {
|
||||||
|
user: 1,
|
||||||
|
alarms: vec![
|
||||||
|
Alarm {
|
||||||
|
id: 1,
|
||||||
|
hour: 10,
|
||||||
|
mins: 20,
|
||||||
|
active: true,
|
||||||
|
repeat: true,
|
||||||
|
},
|
||||||
|
Alarm {
|
||||||
|
id: 2,
|
||||||
|
hour: 11,
|
||||||
|
mins: 15,
|
||||||
|
active: true,
|
||||||
|
repeat: false,
|
||||||
|
},
|
||||||
|
Alarm {
|
||||||
|
id: 3,
|
||||||
|
hour: 5,
|
||||||
|
mins: 30,
|
||||||
|
active: false,
|
||||||
|
repeat: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[launch]
|
||||||
|
fn rocket() -> _ {
|
||||||
|
rocket::build().mount("/", routes![index])
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user