Rename item to entry

This commit is contained in:
2023-05-13 15:39:39 -04:00
parent a331e63466
commit bf40b803a9
10 changed files with 89 additions and 89 deletions

19
src/handlers/entry.rs Normal file
View File

@@ -0,0 +1,19 @@
use axum::{
extract::{Path, State},
Json,
};
use sqlx::PgPool;
use crate::error::Error;
use crate::models::entry::{create_entry, get_entry, CreateEntry, Entry};
pub async fn get(State(pool): State<PgPool>, Path(id): Path<i32>) -> Result<Json<Entry>, Error> {
Ok(Json(get_entry(&pool, id).await?))
}
pub async fn post(
State(pool): State<PgPool>,
Json(payload): Json<CreateEntry>,
) -> Result<Json<Entry>, Error> {
Ok(Json(create_entry(&pool, payload).await?))
}