diff options
Diffstat (limited to 'crates/rocie-server/src/api/get/auth/mod.rs')
| -rw-r--r-- | crates/rocie-server/src/api/get/auth/mod.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/rocie-server/src/api/get/auth/mod.rs b/crates/rocie-server/src/api/get/auth/mod.rs index c51f6a7..0821222 100644 --- a/crates/rocie-server/src/api/get/auth/mod.rs +++ b/crates/rocie-server/src/api/get/auth/mod.rs @@ -1,9 +1,12 @@ use actix_web::web; +use log::info; +use percent_encoding::percent_decode_str; pub(crate) mod inventory; pub(crate) mod product; pub(crate) mod product_parent; pub(crate) mod recipe; +pub(crate) mod recipe_parent; pub(crate) mod unit; pub(crate) mod unit_property; pub(crate) mod user; @@ -17,11 +20,19 @@ pub(crate) fn register_paths(cfg: &mut web::ServiceConfig) { .service(product::products_by_product_parent_id_indirect) .service(product::products_in_storage) .service(product::products_registered) + .service(product::products_without_product_parent) .service(product_parent::product_parents) .service(product_parent::product_parents_toplevel) .service(product_parent::product_parents_under) + .service(recipe::recipe_by_name) .service(recipe::recipe_by_id) .service(recipe::recipes) + .service(recipe::recipes_by_recipe_parent_id_direct) + .service(recipe::recipes_by_recipe_parent_id_indirect) + .service(recipe::recipes_without_recipe_parent) + .service(recipe_parent::recipe_parents) + .service(recipe_parent::recipe_parents_toplevel) + .service(recipe_parent::recipe_parents_under) .service(unit::unit_by_id) .service(unit::units) .service(unit::units_by_property_id) @@ -30,3 +41,20 @@ pub(crate) fn register_paths(cfg: &mut web::ServiceConfig) { .service(user::users) .service(user::user_by_id); } + +/// A String, that is not url-decoded on parse. +struct UrlEncodedString(String); + +impl UrlEncodedString { + /// Percent de-encode a given string + fn percent_decode(&self) -> Result<String, std::str::Utf8Error> { + percent_decode_str(self.0.replace('+', "%20").as_str()) + .decode_utf8() + .map(|s| s.to_string()) + .inspect(|s| info!("Decoded `{}` as `{s}`", self.0)) + } + + fn from_str(inner: &str) -> Self { + Self(inner.to_owned()) + } +} |
