Initial commit with basic axum and sqlx API
This commit is contained in:
9
src/handlers/items.rs
Normal file
9
src/handlers/items.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use axum::{extract::State, Json};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::error::AppError;
|
||||
use crate::models::item::{get_items, Item};
|
||||
|
||||
pub async fn get(State(pool): State<PgPool>) -> Result<Json<Vec<Item>>, AppError> {
|
||||
Ok(Json(get_items(pool).await?))
|
||||
}
|
||||
Reference in New Issue
Block a user