fixes
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -84,6 +84,19 @@ async fn get_value(device_id: web::Path<String>, data: web::Data<AppState>) -> i
|
||||
HttpResponse::Ok().json(messages)
|
||||
}
|
||||
|
||||
#[get("/device/")]
|
||||
async fn get_devices(data: web::Data<AppState>) -> impl Responder {
|
||||
info!("GET - devices - Processing");
|
||||
let devices = match data.db.get_devices().await {
|
||||
Ok(devs) => devs,
|
||||
Err(e) => {
|
||||
error!("Getting Devices from DB failed \n{}", e);
|
||||
return HttpResponse::InternalServerError().finish();
|
||||
}
|
||||
};
|
||||
HttpResponse::Ok().json(devices)
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
env_logger::init();
|
||||
@@ -100,8 +113,9 @@ async fn main() -> std::io::Result<()> {
|
||||
.service(get_telemetry)
|
||||
.service(receive_value)
|
||||
.service(get_value)
|
||||
.service(get_devices)
|
||||
})
|
||||
.bind(("127.0.0.1", 8080))?
|
||||
.bind(("0.0.0.0", 8080))?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user