// rocie - An enterprise grocery management system // // Copyright (C) 2026 Benedikt Peetz // SPDX-License-Identifier: GPL-3.0-or-later // // This file is part of Rocie. // // You should have received a copy of the License along with this program. // If not, see . 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; pub(crate) fn register_paths(cfg: &mut web::ServiceConfig) { cfg.service(inventory::amount_by_id) .service(product::product_by_id) .service(product::product_by_name) .service(product::product_suggestion_by_name) .service(product::products_by_product_parent_id_direct) .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) .service(unit_property::unit_properties) .service(unit_property::unit_property_by_id) .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 { 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()) } }