Add log-init-function and websocket retry

This commit is contained in:
Tobias Reisinger 2023-11-29 01:03:04 +01:00
parent 6536ff0792
commit 50bcac2a1b
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
12 changed files with 73 additions and 69 deletions
emgauwa-lib/src/handlers/v1

View file

@ -9,18 +9,12 @@ use crate::models::{convert_db_list, Controller};
use crate::types::ConnectedControllersType;
#[get("/api/v1/controllers")]
pub async fn index(
pool: web::Data<Pool<Sqlite>>,
connected_controllers: web::Data<ConnectedControllersType>,
) -> Result<HttpResponse, ApiError> {
pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, ApiError> {
let mut pool_conn = pool.acquire().await?;
let db_controllers = DbController::get_all(&mut pool_conn).await?;
let controllers: Vec<Controller> = convert_db_list(&mut pool_conn, db_controllers)?;
let data = connected_controllers.lock().unwrap();
println!("{:?}", *data);
Ok(HttpResponse::Ok().json(controllers))
}