Renamed directories

This commit is contained in:
2023-09-22 16:56:57 -04:00
parent 02a4d840e0
commit 9cf92b8c1f
66 changed files with 11 additions and 28 deletions

View File

@@ -0,0 +1,34 @@
use crate::{error_handler::ServiceError, db::Metadata};
use crate::metars::Metar;
use actix_web::{get, web, HttpResponse};
use log::error;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct MetarsResponse {
pub data: Vec<Metar>,
pub meta: Metadata
}
#[get("metars/{ids}")]
async fn get_all(ids: web::Path<String>) -> HttpResponse {
let airports = match web::block(|| Ok::<_, ServiceError>(async {Metar::get_all(ids.into_inner()).await}))
.await
.unwrap()
.unwrap()
.await {
Ok(a) => a,
Err(err) => {
error!("{}", err);
return err.to_http_response();
}
};
HttpResponse::Ok().json(MetarsResponse {
data: airports,
meta: Metadata { page: 0, limit: 0, pages: 0, total: 0 }
})
}
pub fn init_routes(config: &mut web::ServiceConfig) {
config.service(get_all);
}