Search in sources :

Example 1 with MatchResult2

use of org.webpieces.router.impl.model.MatchResult2 in project webpieces by deanhiller.

the class AbstractRouterImpl method matches.

@Override
public MatchResult2 matches(RouterRequest request, String subPath) {
    Matcher matcher = matchesAndParseParams(request, subPath);
    if (matcher == null)
        return new MatchResult2(false);
    else if (!matcher.matches())
        return new MatchResult2(false);
    Map<String, String> namesToValues = new HashMap<>();
    for (String name : matchInfo.getPathParamNames()) {
        String value = matcher.group(name);
        if (value == null)
            throw new IllegalArgumentException("Bug, something went wrong. request=" + request);
        // convert special characters back to their normal form like '+' to ' ' (space)
        String decodedVal = urlDecode(value);
        namesToValues.put(name, decodedVal);
    }
    return new MatchResult2(namesToValues);
}
Also used : MatchResult2(org.webpieces.router.impl.model.MatchResult2) Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 MatchResult2 (org.webpieces.router.impl.model.MatchResult2)1