-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b83502
commit 861392d
Showing
10 changed files
with
322 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
use crate::Container; | ||
use axum::{extract::Json, http::StatusCode}; | ||
use crate::{ | ||
error_handling::{result_to_handler_with_log, ReturnData}, | ||
Container, | ||
}; | ||
use axum::extract::Json; | ||
use sqlx::{pool::Pool, postgres::Postgres}; | ||
use std::sync::Arc; | ||
use tracing::*; | ||
|
||
pub async fn insert_container( | ||
Json(container): Json<Container>, | ||
conn: Arc<Pool<Postgres>>, | ||
) -> StatusCode { | ||
) -> ReturnData<()> { | ||
info!("Try insert container: {container:?}"); | ||
match crate::database::insert_container::insert_container(&*conn, container.clone()).await { | ||
Ok(()) => { | ||
info!("Success insert container[{}]", &container.id); | ||
StatusCode::ACCEPTED | ||
} | ||
Err(err) => { | ||
error!("Failed insert container[{}]: {err}", &container.id); | ||
StatusCode::BAD_REQUEST | ||
} | ||
} | ||
let res = crate::database::insert_container::insert_container(&*conn, container.clone()).await; | ||
result_to_handler_with_log( | ||
|_| Some(format!("Success insert container[{}]", &container.id)), | ||
|e| Some(format!("{e} [{}]", &container.id)), | ||
&res, | ||
) | ||
.await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.