|
|
|
@ -9,6 +9,7 @@ use axum::Json;
|
|
|
|
|
use axum::Router; |
|
|
|
|
use clap::Parser; |
|
|
|
|
use domain::entry::IncomingEntry; |
|
|
|
|
use domain::entry::OutgoingEntry; |
|
|
|
|
use sqlx::sqlite::SqliteConnectOptions; |
|
|
|
|
use sqlx::sqlite::SqlitePoolOptions; |
|
|
|
|
use sqlx::SqlitePool; |
|
|
|
@ -60,8 +61,12 @@ async fn serve(state: Arc<SqlitePool>, addr: &str) {
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
async fn add_entry( |
|
|
|
|
State(state): State<Arc<SqlitePool>>, |
|
|
|
|
State(pool): State<Arc<SqlitePool>>, |
|
|
|
|
Json(payload): Json<IncomingEntry>, |
|
|
|
|
) -> Json<IncomingEntry> { |
|
|
|
|
Json(payload) |
|
|
|
|
) -> Result<Json<OutgoingEntry>, sqlx::Error> { |
|
|
|
|
let mut transaction = pool.begin().await?; |
|
|
|
|
payload.save(&mut transaction).await?; |
|
|
|
|
transaction.commit().await?; |
|
|
|
|
|
|
|
|
|
Ok(Json(OutgoingEntry { id: "id".into() })) |
|
|
|
|
} |
|
|
|
|