Display basic device information
This commit is contained in:
		@@ -139,6 +139,10 @@ pub async fn secure_server(energy_actor: EnergyActorAddr) -> anyhow::Result<()>
 | 
			
		||||
                "/web_api/devices/list_validated",
 | 
			
		||||
                web::get().to(devices_controller::list_validated),
 | 
			
		||||
            )
 | 
			
		||||
            .route(
 | 
			
		||||
                "/web_api/device/{id}",
 | 
			
		||||
                web::get().to(devices_controller::get_single),
 | 
			
		||||
            )
 | 
			
		||||
            .route(
 | 
			
		||||
                "/web_api/device/{id}/validate",
 | 
			
		||||
                web::post().to(devices_controller::validate_device),
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user