@Override public List<RouteMatch> findRoutes(String requestMethod, String requestUri) { log.trace("Finding route matches for {} '{}'", requestMethod, requestUri); // force compile routes compileRoutes(); List<RouteMatch> routeMatches = new ArrayList<>(); for (Route route : compiledRoutes) { boolean methodMatches = route.getRequestMethod().equals(requestMethod) || route.getRequestMethod().equals(HttpConstants.Method.ANY); if (methodMatches) { String uriPattern = route.getUriPattern(); Map<String, String> parameters = uriMatcher.match(requestUri, uriPattern); if (parameters != null) { // complete matching => add route match ro returned list routeMatches.add(new RouteMatch(route, parameters)); } } } log.debug("Found {} route matches for {} '{}'", routeMatches.size(), requestMethod, requestUri); return routeMatches; }
protected void processRouteInterceptors(RouteContext routeContext) { if (interceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler interceptor : interceptors) { // create a route for interceptor Route route = new Route(routeContext.getRequestMethod(), routeContext.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", Interceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); route.bindAll(routeContext.getRoute().getAttributes()); // add route in chain RouteMatch match = new RouteMatch(route, null); chain.add(match); } // TODO DefaultRouteContext is hardcoded RouteContext context = new DefaultRouteContext(routeContext.getApplication(), routeContext.getRequest(), routeContext.getResponse(), chain); context.next(); }
protected void processRouteInterceptors(Context context) { if (routeInterceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler<Context> interceptor : routeInterceptors) { Route route = new Route(context.getRequestMethod(), context.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", RouteInterceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); RouteMatch match = new RouteMatch(route, null); chain.add(match); } Context subContext = new Context(context, chain); subContext.next(); }
protected void processRouteInterceptors(Context context) { if (routeInterceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler<Context> interceptor : routeInterceptors) { Route route = new Route(context.getRequestMethod(), context.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", RouteInterceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); RouteMatch match = new RouteMatch(route, null); chain.add(match); } Context subContext = new Context(context, chain); subContext.next(); }
protected void processRouteInterceptors(RouteContext routeContext) { if (interceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler interceptor : interceptors) { // create a route for interceptor Route route = new Route(routeContext.getRequestMethod(), routeContext.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", Interceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); route.bindAll(routeContext.getRoute().getAttributes()); // add route in chain RouteMatch match = new RouteMatch(route, null); chain.add(match); } // TODO DefaultRouteContext is hardcoded RouteContext context = new DefaultRouteContext(routeContext.getApplication(), routeContext.getRequest(), routeContext.getResponse(), chain); context.next(); }