serve frontend by backend if feature flag is set

This commit is contained in:
2022-12-08 13:06:19 +01:00
parent b77b34442b
commit 21520a7b1c
5 changed files with 177 additions and 13 deletions

View File

@@ -1,9 +1,13 @@
mod parser;
#[macro_use]
extern crate rocket;
mod parser;
#[cfg(feature = "static")]
mod embed;
use rocket::serde::json::Json;
#[cfg(feature = "static")]
use crate::embed::CustomHandler;
use crate::parser::lsblk_parser::{Disk, parse_lsblk};
use crate::parser::mdstat_parser::{MdRaidSystem, parse_mdstat};
@@ -20,10 +24,10 @@ fn get_disks() -> Json<Vec<Disk>> {
#[rocket::main]
async fn main() -> Result<(), rocket::Error> {
println!("init");
let _rocket = rocket::build()
.mount("/api", routes![get_raid_devices, get_disks])
.launch()
.await?;
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?;
Ok(())
}