aboutsummaryrefslogtreecommitdiff
path: root/src/routes/devices.rs
blob: 616441cfaa4a06e0090b427657fec2fc625d7a5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::error::Error;
use crate::storage::Device;
use axum::Json;
use serde_json::{json, Value};
use tracing::{debug, info};

#[utoipa::path(
    get,
    path = "/devices",
    responses(
        (status = 200, description = "Get an array of all `Device`s", body = [Vec<Device>])
    ),
    security((), ("api_key" = []))
)]
pub async fn get(
) -> Result<Json<Value>, Error> {
    info!("get all devices");

    let devices = Device::read_all()?;

    debug!("got devices");

    Ok(Json(json!(devices)))
}