cannot find macro rocket_uri_macro_target_url #2489
Replies: 1 comment
-
As far as I understand the It requires you to pass either a string literal or a named route, where the route is your actual route fn. It is a proc macro, and has to be able to generate the code at compile time. This would be impossible here, because your given path can only be known at runtime. One possible solution off the top of my head is to match against your routes manually. #[get("/redirect/<path>")]
pub fn redirect(path: String) -> Redirect {
let route = match path.as_str() {
"hello" => uri!(hello()),
_ => uri!("/"),
};
Redirect::to(route)
}
#[get("/hello")]
async fn hello() -> String {
"Hello, world!".to_string()
} Alternatively, you could side-step it by using |
Beta Was this translation helpful? Give feedback.
-
I am trying to redirect the response but when I assigning the redirect url from mongodb response I am getting cannot find macro
rocket_uri_macro_target_url
.Here is my code
Here is the error message
Beta Was this translation helpful? Give feedback.
All reactions