aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/waifus.rs
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-04-27 14:44:33 -0400
committerCara Salter <cara@devcara.com>2022-04-27 14:44:33 -0400
commitbc3132f22f3470d8b1d8189e23393d3bb4577480 (patch)
treeb8d6466e4191a4e7e5e4a755102e82ffbff56b36 /src/handlers/waifus.rs
parent9696669ff126cd2bcbc31e90651b464432b7947f (diff)
downloadsolard-bc3132f22f3470d8b1d8189e23393d3bb4577480.tar.gz
solard-bc3132f22f3470d8b1d8189e23393d3bb4577480.zip
List waifus
Also use environment variables and new error types
Diffstat (limited to 'src/handlers/waifus.rs')
-rw-r--r--src/handlers/waifus.rs18
1 files changed, 18 insertions, 0 deletions
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<Json<Vec<Waifu>>> {
+ 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))
+}
+