diff options
| author | Joe Carstairs <me@joeac.net> | 2024-11-17 09:29:32 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2024-11-17 09:30:04 +0000 |
| commit | 10f071447594f2bdcec84a461df9ad648f71f44b (patch) | |
| tree | 645924a4948f39a4d9e2ec270d79fc6c2a3a937a /rust/schist_backend/src/routes/category.rs | |
| parent | 1ae19eb3315c40e3f9062592c27fa76c11cf626c (diff) | |
Renames app to 'schist'
Diffstat (limited to 'rust/schist_backend/src/routes/category.rs')
| -rw-r--r-- | rust/schist_backend/src/routes/category.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/rust/schist_backend/src/routes/category.rs b/rust/schist_backend/src/routes/category.rs new file mode 100644 index 0000000..1f07452 --- /dev/null +++ b/rust/schist_backend/src/routes/category.rs @@ -0,0 +1,18 @@ +use schist_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 }) +} |
