pub fn match_request(req: &Request, interactions: &Vec<Interaction>) -> MatchResult {
    let match_results = interactions
        .into_iter()
        .map(|i| (i.clone(), pact_matching::match_request(i.request.clone(), req.clone())))
        .sorted_by(|i1, i2| {
            let list1 = i1.1.clone().into_iter().map(|m| m.mismatch_type()).unique().count();
            let list2 = i2.1.clone().into_iter().map(|m| m.mismatch_type()).unique().count();
            Ord::cmp(&list1, &list2)
        });
    match match_results.first() {
        Some(res) => {
            if res.1.is_empty() {
                MatchResult::RequestMatch(res.0.clone())
            } else if method_or_path_mismatch(&res.1) {
                MatchResult::RequestNotFound(req.clone())
            } else {
                MatchResult::RequestMismatch(res.0.clone(), res.1.clone())
            }
        },
        None => MatchResult::RequestNotFound(req.clone())
    }
}
///
/// Matches a request against a list of interactions
///
Matches a request against a list of interactions
Matches a request against a list of interactions
pub fn match_request(req: &Request, interactions: &Vec<Interaction>) -> MatchResult {
    let match_results = interactions
        .into_iter()
        .map(|i| (i.clone(), pact_matching::match_request(i.request.clone(), req.clone())))
        .sorted_by(|i1, i2| {
            let list1 = i1.1.clone().into_iter().map(|m| m.mismatch_type()).unique().count();
            let list2 = i2.1.clone().into_iter().map(|m| m.mismatch_type()).unique().count();
            Ord::cmp(&list1, &list2)
        });
    match match_results.first() {
        Some(res) => {
            if res.1.is_empty() {
                MatchResult::RequestMatch(res.0.clone())
            } else if method_or_path_mismatch(&res.1) {
                MatchResult::RequestNotFound(req.clone())
            } else {
                MatchResult::RequestMismatch(res.0.clone(), res.1.clone())
            }
        },
        None => MatchResult::RequestNotFound(req.clone())
    }
}
pub fn match_request ( req : & Request , interactions : & Vec < Interaction > ) -> MatchResult { let match_results = interactions . into_iter ( ) . map ( | i | ( i . clone ( ) , pact_matching :: match_request ( i . request . clone ( ) , req . clone ( ) ) ) ) . sorted_by ( | i1 , i2 | { let list1 = i1 . 1 . clone ( ) . into_iter ( ) . map ( | m | m . mismatch_type ( ) ) . unique ( ) . count ( ) ; let list2 = i2 . 1 . clone ( ) . into_iter ( ) . map ( | m | m . mismatch_type ( ) ) . unique ( ) . count ( ) ; Ord :: cmp ( & list1 , & list2 ) } ) ; match match_results . first ( ) { Some ( res ) => { if res . 1 . is_empty ( ) { MatchResult :: RequestMatch ( res . 0 . clone ( ) ) } else if method_or_path_mismatch ( & res . 1 ) { MatchResult :: RequestNotFound ( req . clone ( ) ) } else { MatchResult :: RequestMismatch ( res . 0 . clone ( ) , res . 1 . clone ( ) ) } } , None => MatchResult :: RequestNotFound ( req . clone ( ) ) } }
Matches a request against a list of interactions
Matches a request against a list of interactions
req
&Request
interactions
&Vec<Interaction>
req
&Request
interactions
&Vec<Interaction>