diff options
author | Joris | 2023-11-25 08:59:39 +0100 |
---|---|---|
committer | Joris | 2023-11-25 08:59:39 +0100 |
commit | bb906d8ecc796f6b71dda1851d6bd0aa91c6bce5 (patch) | |
tree | cf98c0d9466e0338992c94060d09ac90862178c5 /src/controller/categories.rs | |
parent | 936871e6ba92a23b1956b30272af8c96951c7c2d (diff) |
Upgrade dependencies
Diffstat (limited to 'src/controller/categories.rs')
-rw-r--r-- | src/controller/categories.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/controller/categories.rs b/src/controller/categories.rs index b1a3664..ff2d8e7 100644 --- a/src/controller/categories.rs +++ b/src/controller/categories.rs @@ -1,4 +1,6 @@ -use hyper::{Body, Response}; +use http_body_util::Full; +use hyper::body::Bytes; +use hyper::Response; use std::collections::HashMap; use tera::Context; @@ -12,7 +14,7 @@ use crate::validation; pub async fn table( wallet: &Wallet, query: queries::Categories, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let categories = db::categories::list(&wallet.pool).await; let mut context = Context::new(); @@ -29,7 +31,7 @@ pub async fn table( ) } -pub async fn create_form(wallet: &Wallet) -> Response<Body> { +pub async fn create_form(wallet: &Wallet) -> Response<Full<Bytes>> { create_form_feedback(wallet, HashMap::new(), None).await } @@ -37,7 +39,7 @@ async fn create_form_feedback( wallet: &Wallet, form: HashMap<String, String>, error: Option<String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let mut context = Context::new(); context.insert("header", &templates::Header::Categories); context.insert("connected_user", &wallet.user.clone()); @@ -55,7 +57,7 @@ async fn create_form_feedback( pub async fn create( wallet: &Wallet, form: HashMap<String, String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let error = |e: &str| { create_form_feedback(wallet, form.clone(), Some(e.to_string())) }; @@ -73,7 +75,7 @@ pub async fn create( } } -pub async fn update_form(id: i64, wallet: &Wallet) -> Response<Body> { +pub async fn update_form(id: i64, wallet: &Wallet) -> Response<Full<Bytes>> { update_form_feedback(id, wallet, HashMap::new(), None).await } @@ -82,7 +84,7 @@ async fn update_form_feedback( wallet: &Wallet, form: HashMap<String, String>, error: Option<String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let category = db::categories::get(&wallet.pool, id).await; let is_category_used = db::payments::is_category_used(&wallet.pool, id).await; @@ -108,7 +110,7 @@ pub async fn update( id: i64, wallet: &Wallet, form: HashMap<String, String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let error = |e: &str| { update_form_feedback(id, wallet, form.clone(), Some(e.to_string())) }; @@ -126,7 +128,7 @@ pub async fn update( } } -pub async fn delete(id: i64, wallet: &Wallet) -> Response<Body> { +pub async fn delete(id: i64, wallet: &Wallet) -> Response<Full<Bytes>> { if db::categories::delete(&wallet.pool, id).await { utils::redirect("/categories") } else { |