Rename item to entry
This commit is contained in:
@@ -2,8 +2,8 @@ use axum::{extract::State, Json};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::models::item::{get_items, Item};
|
||||
use crate::models::entry::{get_entries, Entry};
|
||||
|
||||
pub async fn get(State(pool): State<PgPool>) -> Result<Json<Vec<Item>>, Error> {
|
||||
Ok(Json(get_items(&pool).await?))
|
||||
pub async fn get(State(pool): State<PgPool>) -> Result<Json<Vec<Entry>>, Error> {
|
||||
Ok(Json(get_entries(&pool).await?))
|
||||
}
|
||||
19
src/handlers/entry.rs
Normal file
19
src/handlers/entry.rs
Normal 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?))
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
use axum::{
|
||||
extract::{Path, State},
|
||||
Json,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::models::item::{create_item, get_item, CreateItem, Item};
|
||||
|
||||
pub async fn get(State(pool): State<PgPool>, Path(id): Path<i32>) -> Result<Json<Item>, Error> {
|
||||
Ok(Json(get_item(&pool, id).await?))
|
||||
}
|
||||
|
||||
pub async fn post(
|
||||
State(pool): State<PgPool>,
|
||||
Json(payload): Json<CreateItem>,
|
||||
) -> Result<Json<Item>, Error> {
|
||||
Ok(Json(create_item(&pool, payload).await?))
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
pub mod feed;
|
||||
pub mod feeds;
|
||||
pub mod item;
|
||||
pub mod items;
|
||||
pub mod entry;
|
||||
pub mod entries;
|
||||
|
||||
Reference in New Issue
Block a user