Add fmt options and move handlers
This commit is contained in:
parent
50bcac2a1b
commit
fdca5b7277
28 changed files with 85 additions and 70 deletions
emgauwa-lib/src/handlers/v1
|
@ -1,20 +0,0 @@
|
|||
use actix_web::{get, web, HttpResponse};
|
||||
|
||||
use sqlx::{Pool, Sqlite};
|
||||
|
||||
use crate::db::DbController;
|
||||
|
||||
use crate::handlers::errors::ApiError;
|
||||
use crate::models::{convert_db_list, Controller};
|
||||
use crate::types::ConnectedControllersType;
|
||||
|
||||
#[get("/api/v1/controllers")]
|
||||
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)?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(controllers))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue