aboutsummaryrefslogtreecommitdiff
path: root/src/routes/devices.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/devices.rs')
-rw-r--r--src/routes/devices.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/routes/devices.rs b/src/routes/devices.rs
new file mode 100644
index 0000000..616441c
--- /dev/null
+++ b/src/routes/devices.rs
@@ -0,0 +1,24 @@
1use crate::error::Error;
2use crate::storage::Device;
3use axum::Json;
4use serde_json::{json, Value};
5use tracing::{debug, info};
6
7#[utoipa::path(
8 get,
9 path = "/devices",
10 responses(
11 (status = 200, description = "Get an array of all `Device`s", body = [Vec<Device>])
12 ),
13 security((), ("api_key" = []))
14)]
15pub async fn get(
16) -> Result<Json<Value>, Error> {
17 info!("get all devices");
18
19 let devices = Device::read_all()?;
20
21 debug!("got devices");
22
23 Ok(Json(json!(devices)))
24}