diff --git a/src/cases.rs b/src/cases.rs index 73c2be8..fbbeac4 100644 --- a/src/cases.rs +++ b/src/cases.rs @@ -1,7 +1,7 @@ -use crate::types::*; use crate::AppState; +use crate::types::*; use actix_web::web::Data; -use actix_web::{get, web, HttpResponse, Responder}; +use actix_web::{HttpResponse, Responder, get, web}; use serde_json::to_string; use sqlx::query_as; @@ -49,8 +49,8 @@ async fn get_case_items(query: web::Query, app_state: Data) "SELECT * FROM items_cases WHERE \"case\" = $1", case.id ) - .fetch_all(&app_state.database) - .await; + .fetch_all(&app_state.database) + .await; if items_cases.is_err() { return HttpResponse::NotFound().finish(); } diff --git a/src/items.rs b/src/items.rs index e14a495..444843d 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1,7 +1,7 @@ -use crate::types::*; use crate::AppState; +use crate::types::*; use actix_web::web::Data; -use actix_web::{get, web, HttpResponse, Responder}; +use actix_web::{HttpResponse, Responder, get, web}; use serde_json::to_string; use sqlx::query_as; @@ -51,8 +51,8 @@ async fn get_item_cases(query: web::Query, app_state: Data) "SELECT * FROM items_cases WHERE \"item\" = $1", item.id ) - .fetch_all(&app_state.database) - .await; + .fetch_all(&app_state.database) + .await; if items_cases.is_err() { return HttpResponse::NotFound().finish(); } diff --git a/src/main.rs b/src/main.rs index 549521e..d5ba35a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ mod cases; +mod inventories; mod items; mod types; mod users; @@ -10,7 +11,7 @@ use users::*; use utils::*; use actix_web::web::Data; -use actix_web::{middleware::DefaultHeaders, App, HttpServer}; +use actix_web::{App, HttpServer, middleware::DefaultHeaders}; use sqlx::sqlite::SqlitePool; #[derive(Clone)] @@ -32,10 +33,14 @@ async fn main() -> std::io::Result<()> { }); HttpServer::new(move || { App::new() - .wrap(DefaultHeaders::new().add(( - "Access-Control-Allow-Origin", - app_state.allow_origins.join(","), - )).add(("Access-Control-Allow-Credentials", "true"))) + .wrap( + DefaultHeaders::new() + .add(( + "Access-Control-Allow-Origin", + app_state.allow_origins.join(","), + )) + .add(("Access-Control-Allow-Credentials", "true")), + ) .service(login) .service(register) .service(logout) @@ -48,7 +53,7 @@ async fn main() -> std::io::Result<()> { .service(options) .app_data(app_state.clone()) }) - .bind(("127.0.0.1", 8000))? - .run() - .await + .bind(("127.0.0.1", 8000))? + .run() + .await } diff --git a/src/utils.rs b/src/utils.rs index 1b9b7f4..7ce9b7a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ use crate::AppState; use actix_web::web::Data; -use actix_web::{options, HttpResponse, Responder}; +use actix_web::{HttpResponse, Responder, options}; // This is needed for the web client. // This returns the same options for every path of the api @@ -12,7 +12,10 @@ async fn options(app_state: Data) -> impl Responder { app_state.allow_origins.join(","), )) .append_header(("Access-Control-Allow-Methods", "GET, OPTIONS")) - .append_header(("Access-Control-Allow-Headers", "Content-Type, Authorization")) + .append_header(( + "Access-Control-Allow-Headers", + "Content-Type, Authorization", + )) .append_header(("Access-Control-Allow-Credentials", "true")) .finish() }