Search in sources :

Example 1 with FilterInfo

use of org.webpieces.router.impl.FilterInfo in project webpieces by deanhiller.

the class R1RouterBuilder method findMatchingFilters.

public List<FilterInfo<?>> findMatchingFilters(String path, boolean isHttps) {
    List<FilterInfo<?>> matchingFilters = new ArrayList<>();
    for (FilterInfo<?> info : routeFilters) {
        if (!info.securityMatch(isHttps))
            //skip this filter
            continue;
        Pattern patternToMatch = info.getPatternToMatch();
        Matcher matcher = patternToMatch.matcher(path);
        if (matcher.matches()) {
            matchingFilters.add(0, info);
        }
    }
    return matchingFilters;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) FilterInfo(org.webpieces.router.impl.FilterInfo)

Example 2 with FilterInfo

use of org.webpieces.router.impl.FilterInfo in project webpieces by deanhiller.

the class R1RouterBuilder method applyFilters.

public void applyFilters(WebAppMeta rm) {
    ReverseRoutes reverseRoutes = holder.getReverseRoutes();
    Collection<RouteMeta> metas = reverseRoutes.getAllRouteMetas();
    for (RouteMeta meta : metas) {
        String path = meta.getRoute().getFullPath();
        List<FilterInfo<?>> filters = findMatchingFilters(path, meta.getRoute().isHttpsRoute());
        meta.setFilters(filters);
    }
    List<L2DomainRoutes> allDomains = allRouting.getAllDomains();
    for (L2DomainRoutes domainRoutes : allDomains) {
        applyFilters(domainRoutes, rm);
    }
}
Also used : RouteMeta(org.webpieces.router.impl.RouteMeta) ReverseRoutes(org.webpieces.router.impl.ReverseRoutes) FilterInfo(org.webpieces.router.impl.FilterInfo)

Aggregations

FilterInfo (org.webpieces.router.impl.FilterInfo)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 ReverseRoutes (org.webpieces.router.impl.ReverseRoutes)1 RouteMeta (org.webpieces.router.impl.RouteMeta)1