1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use actix_web::HttpRequest; use dbui_service::Router; use dbui_core::{Error, Result}; #[derive(derive_more::Constructor, Debug)] pub(crate) struct RequestRouter { req: HttpRequest } impl Router for RequestRouter { fn route(&self, path: &str, args: &[&str]) -> Result<String> { self .req .url_for(path, args) .map(|x| x.path().into()) .map_err(|_| Error::from(format!("Unable to find route for [{}]", path))) } }