diff options
| author | Joe Carstairs <me@joeac.net> | 2024-11-17 09:23:28 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2024-11-17 09:23:28 +0000 |
| commit | 1ae19eb3315c40e3f9062592c27fa76c11cf626c (patch) | |
| tree | 09d9ce380795971f4b50e1d4b0ca3c57c9e1db1a /rust/app/src/routes/category.rs | |
| parent | 1a494937021561595d0fb29e26fb707aef9e55de (diff) | |
Renames workspace folder
Diffstat (limited to 'rust/app/src/routes/category.rs')
| -rw-r--r-- | rust/app/src/routes/category.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/rust/app/src/routes/category.rs b/rust/app/src/routes/category.rs new file mode 100644 index 0000000..ca021fc --- /dev/null +++ b/rust/app/src/routes/category.rs @@ -0,0 +1,18 @@ +use budgeting_app_core::{ + models::category::Category, + queries::categories::get_all_categories as get_all_categories_query, +}; +use rocket::get; +use rocket::http::Status; +use rocket::serde::json::Json; + +use crate::databases::UserDataDb; + +#[get("/category")] +pub async fn get_all_categories(user_data_db: UserDataDb) -> Result<Json<Vec<Category>>, Status> { + user_data_db + .run(get_all_categories_query) + .await + .map(Json) + .map_err(|_| Status { code: 500 }) +} |
