oswilno/crates/oswilno-parking-space/src/lib.rs

20 lines
519 B
Rust
Raw Normal View History

2023-07-27 22:29:04 +02:00
use actix_web::web::{Data, ServiceConfig};
2023-07-27 17:36:30 +02:00
use actix_web::{get, HttpResponse};
2023-07-26 11:16:29 +02:00
2023-07-27 17:36:30 +02:00
pub fn mount(config: &mut ServiceConfig) {
config.service(all_parking_spaces);
}
#[get("/ps")]
async fn all_parking_spaces(db: Data<sea_orm::DatabaseConnection>) -> HttpResponse {
2023-07-27 22:29:04 +02:00
use oswilno_contract::prelude::*;
use oswilno_contract::*;
2023-07-27 17:36:30 +02:00
use parking_spaces::*;
2023-07-27 22:29:04 +02:00
use sea_orm::*;
2023-07-27 17:36:30 +02:00
let db = db.into_inner();
let spaces: Vec<Model> = Entity::find().all(&*db).await.unwrap();
HttpResponse::Ok().json(spaces)
}