aboutsummaryrefslogtreecommitdiff
path: root/src/routes
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-08-10 21:21:34 +0200
committerfxqnlr <[email protected]>2024-08-10 21:21:34 +0200
commit76c89b47fd74e069f9db73503a5131a5a60b8516 (patch)
tree5c6beb74abe986554b9b56cac4673b8e0c743e92 /src/routes
parent3e8866c07fbd6c2819ff3833e52ede9158a9862d (diff)
downloadwebol-76c89b47fd74e069f9db73503a5131a5a60b8516.tar
webol-76c89b47fd74e069f9db73503a5131a5a60b8516.tar.gz
webol-76c89b47fd74e069f9db73503a5131a5a60b8516.zip
add 'devices' path to request all available devices
Diffstat (limited to 'src/routes')
-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}