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-core/src/handlers/v1
17
emgauwa-core/src/handlers/v1/controllers.rs
Normal file
17
emgauwa-core/src/handlers/v1/controllers.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use actix_web::{get, web, HttpResponse};
|
||||
use emgauwa_lib::db::DbController;
|
||||
use emgauwa_lib::models::{convert_db_list, Controller};
|
||||
use sqlx::{Pool, Sqlite};
|
||||
|
||||
use crate::handlers::errors::ApiError;
|
||||
|
||||
#[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