I am a Rust beginner and I needed some help with creating path Filters. The stripped down code looks like this:
pub fn requests_filter() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
let authenticate = warp::get()
.and(warp::path("/auth")
.and_then(perform_authentication);
let get_request = warp::get()
.and(
warp::filters::query::raw()
.or(warp::any().map(|| String::default()))
.unify(),
)
.and(get_header)
.and_then(process_get_request);
authenticate.or(get_request)
}
I need to combine the 2 filters so that if I get a auth request(/auth) then it should execute just the first filter and not the second. For all other GET requests it should just execute 2nd path filter. The issue I am having in the above code is the second path filter gets executed when there is some authentication error. I want to it to return and not execute the second path filter. Could you please let me know how to solve this. I looked at routing.rs example but wasnt able to figure this out. Thanks in advance!