Display basic device information

This commit is contained in:
2024-07-18 20:06:46 +02:00
parent 7be81fe0e9
commit 1ce9ca3321
5 changed files with 135 additions and 3 deletions

View File

@ -33,6 +33,18 @@ pub struct DeviceInPath {
id: DeviceId,
}
/// Get a single device information
pub async fn get_single(actor: WebEnergyActor, id: web::Path<DeviceInPath>) -> HttpResult {
let Some(dev) = actor
.send(energy_actor::GetSingleDevice(id.id.clone()))
.await?
else {
return Ok(HttpResponse::NotFound().json("Requested device was not found!"));
};
Ok(HttpResponse::Ok().json(dev))
}
/// Validate a device
pub async fn validate_device(actor: WebEnergyActor, id: web::Path<DeviceInPath>) -> HttpResult {
actor