Files
Raid_Manager/lib/src/main.rs

34 lines
778 B
Rust
Raw Normal View History

2022-12-04 15:02:07 +01:00
#[macro_use]
extern crate rocket;
mod parser;
#[cfg(feature = "static")]
mod embed;
2022-12-04 15:02:07 +01:00
use rocket::serde::json::Json;
#[cfg(feature = "static")]
use crate::embed::CustomHandler;
2022-12-05 23:18:32 +01:00
use crate::parser::lsblk_parser::{Disk, parse_lsblk};
2022-12-05 00:03:22 +01:00
use crate::parser::mdstat_parser::{MdRaidSystem, parse_mdstat};
2022-12-04 15:02:07 +01:00
#[get("/raiddevices")]
fn get_raid_devices() -> Json<MdRaidSystem> {
Json(parse_mdstat())
}
2022-12-05 23:18:32 +01:00
#[get("/disks")]
fn get_disks() -> Json<Vec<Disk>> {
Json(parse_lsblk())
}
2022-12-04 15:02:07 +01:00
#[rocket::main]
async fn main() -> Result<(), rocket::Error> {
println!("init");
let b = rocket::build();
let b = b.mount("/api", routes![get_raid_devices, get_disks]);
#[cfg(feature = "static")]
let b = b.mount("/", CustomHandler{});
let _rocket = b.launch().await?;
2022-12-04 15:02:07 +01:00
Ok(())
2022-12-06 22:22:24 +01:00
}