You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When some route return NOT FOUND (404) I get METHOD NOT ALLOWED (405) when there is a route that have the method at the start of the paths instead of at the end:
When put is at the start:
let problematic_route = warp::put().and(warp::path("api")).map(move || {"Hello".to_string()});
VS when `put is at the end:
let problematic_route = warp::path("api").and(warp::put()).map(move || {"Hello".to_string()});
I did not see anywhere that putting the method at the start will cause this which is why I'm considering it as a bug
The following is working:
let crates = warp::path("b")// Simulating .and(warp::fs::dir(<some-dir>)) for simplicity.and(warp::get()).and(custom_filter()).with(warp::trace::request());let problematic_route = warp::path("api").and(warp::put()).map(move || {"Hello".to_string()});let routes = problematic_route
.or(crates);
Almost complete code
The following does not work:
let crates = warp::path("b")// Simulating .and(warp::fs::dir(<some-dir>)) for simplicity.and(warp::get()).and(custom_filter()).with(warp::trace::request());// <-------- This does not worklet problematic_route =
warp::put().and(warp::path("api")).map(move || {"Hello".to_string()});let routes = problematic_route
.or(crates);
Custom filter is:
fncustom_filter() -> implFilter<Extract=(String,),Error=Rejection> + Copy{
warp::path::tail()// I use `and_then` to simulate warp::fs::dir(<some-dir>) which does that as well.and_then(|s:Tail| asyncmove{let route = s.as_str();if !route.ends_with("something"){returnErr(reject::not_found());}Ok(route.to_string())})}
The text was updated successfully, but these errors were encountered:
Thank you for explaining the workaround. I have the same problem, the workaround helps.
I'd be interested to know what the root-cause of this issue is.
Maybe related to #1017
Version
v0.3.7
Platform
Description
Reproduction Repo
When some route return
NOT FOUND
(404) I getMETHOD NOT ALLOWED
(405) when there is a route that have the method at the start of the paths instead of at the end:When
put
is at the start:VS when `put is at the end:
I did not see anywhere that putting the method at the start will cause this which is why I'm considering it as a bug
The following is working:
Almost complete code
The following does not work:
Custom filter is:
The text was updated successfully, but these errors were encountered: