Replies: 9 comments
-
only the part For example: .push(
Router::with_path("/library/metadata/<**rest>")
.hoop(disable_related_query)
.handle(proxy.clone()),
) when you request url is |
Beta Was this translation helpful? Give feedback.
-
Yeah I find that unexpected. I would expect the whole path to be proxied. Not only the rest part |
Beta Was this translation helpful? Give feedback.
-
What's the suggested for doing this then? I need to add different middleware to different proxy routes. I don't want to apply it to every routes
|
Beta Was this translation helpful? Give feedback.
-
You can use a middlware to put |
Beta Was this translation helpful? Give feedback.
-
yeah that's the only solution for now. Not really dry tho, as I have to apply my own path filters. But at least I know that this is by design. |
Beta Was this translation helpful? Give feedback.
-
Maybe I can add a function to allow set custom way to build the target url. You can check the proxy branch. pub fn default_url_rest_getter(req: &Request, _depot: &Depot) -> String {
let param = req.params().iter().find(|(key, _)| key.starts_with('*'));
let mut rest = if let Some((_, rest)) = param {
encode_url_path(rest)
} else {
"".into()
};
if let Some(query) = req.uri().query() {
rest = format!("{}?{}", rest, query);
}
rest
}
/// Set url rest getter.
#[inline]
pub fn url_rest_getter<G>(mut self, url_rest_getter: G) -> Self
where
G: Fn(&Request, &Depot) -> String + Send + Sync + 'static,
{
self.url_rest_getter = Box::new(url_rest_getter);
self
} |
Beta Was this translation helpful? Give feedback.
-
yeah that works. Im already overloading exactly that part. But this is much cleaner |
Beta Was this translation helpful? Give feedback.
-
Give me a ping when this is merged so I can switch the branch |
Beta Was this translation helpful? Give feedback.
-
@sarendsen This is merged, Version 0.50.3 released. |
Beta Was this translation helpful? Give feedback.
-
When I proxy a route like this
The request url of
http://localhost/library/metadata/500
will result in an proxied request ofhttp://upstream
, without an path. While you would expect the path to be included in the proxy request: akahttp://upstream/library/metadata/500
Beta Was this translation helpful? Give feedback.
All reactions