From bc3132f22f3470d8b1d8189e23393d3bb4577480 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Wed, 27 Apr 2022 14:44:33 -0400 Subject: List waifus Also use environment variables and new error types --- src/handlers/waifus.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/handlers/waifus.rs (limited to 'src/handlers/waifus.rs') diff --git a/src/handlers/waifus.rs b/src/handlers/waifus.rs new file mode 100644 index 0000000..117ba15 --- /dev/null +++ b/src/handlers/waifus.rs @@ -0,0 +1,18 @@ +use axum::{response::IntoResponse, Json}; + +use tracing::{error, instrument}; + +use waifulib::house::House; +use waifulib::waifu::Waifu; + +use crate::errors::*; + +pub async fn list() -> JsonResult>> { + let con_url = std::env::var("QEMU_URL").unwrap_or("qemu:///system".to_string()); + let mut house: House = House::new(con_url)?; + + let inhabitants = house.inhabitants()?; + + Ok(Json(inhabitants)) +} + -- cgit v1.2.3