/** * Test if the route matches the given verb, path, content type and accept header. * * @param method A HTTP verb. * @param path Current HTTP path. * @param contentType The <code>Content-Type</code> header. * @param accept The <code>Accept</code> header. * @return A route or an empty optional. */ @Nonnull public Optional<Route> matches(final String method, final String path, final MediaType contentType, final List<MediaType> accept) { String fpath = method + path; if (excludes.size() > 0 && excludes(fpath)) { return Optional.empty(); } RouteMatcher matcher = cpattern.matcher(fpath); if (matcher.matches()) { List<MediaType> result = MediaType.matcher(accept).filter(this.produces); if (result.size() > 0 && canConsume(contentType)) { // keep accept when */* List<MediaType> produces = result.size() == 1 && result.get(0).name().equals("*/*") ? accept : this.produces; return Optional .of(asRoute(method, matcher, produces, new RouteSourceImpl(declaringClass, line))); } } return Optional.empty(); }
.produces(produces) .consumes(consumes) .excludes(excludes) .declaringClass(routeClass.getName()) .line(classInfo.startAt(method) - 1)
/** * Test if the route matches the given verb, path, content type and accept header. * * @param method A HTTP verb. * @param path Current HTTP path. * @param contentType The <code>Content-Type</code> header. * @param accept The <code>Accept</code> header. * @return A route or an empty optional. */ @Nonnull public Optional<Route> matches(final String method, final String path, final MediaType contentType, final List<MediaType> accept) { String fpath = method + path; if (excludes.size() > 0 && excludes(fpath)) { return Optional.empty(); } RouteMatcher matcher = cpattern.matcher(fpath); if (matcher.matches()) { List<MediaType> result = MediaType.matcher(accept).filter(this.produces); if (result.size() > 0 && canConsume(contentType)) { // keep accept when */* List<MediaType> produces = result.size() == 1 && result.get(0).name().equals("*/*") ? accept : this.produces; return Optional .of(asRoute(method, matcher, produces, new RouteSourceImpl(declaringClass, line))); } } return Optional.empty(); }
public Route.Definition apply(final Route.Definition route) { attrs.build().forEach(route::attr); if (name != null) { route.name(name); } if (prefix != null) { route.name(prefix + "/" + route.name()); } if (consumes != null) { route.consumes(consumes); } if (produces != null) { route.produces(produces); } if (excludes != null) { route.excludes(excludes); } if (mapper != null) { route.map(mapper); } if (renderer != null) { route.renderer(renderer); } return route; } }
router.use(conf.getString("pac4j.callback.method"), callbackPath, new Pac4jCallback(pac4j, callbackRedirectTo, multiProfile, renewSession)) .excludes(excludePaths) .name("pac4j(Callback)"); excludes.remove("/**"); router.use(conf.getString("pac4j.securityFilter.method"), pattern, filter) .excludes(excludes) .name("pac4j(" + filter + ")"); });
.produces(produces) .consumes(consumes) .excludes(excludes) .declaringClass(routeClass.getName()) .line(classInfo.startAt(method) - 1)
public Route.Definition apply(final Route.Definition route) { attrs.build().forEach(route::attr); if (name != null) { route.name(name); } if (prefix != null) { route.name(prefix + "/" + route.name()); } if (consumes != null) { route.consumes(consumes); } if (produces != null) { route.produces(produces); } if (excludes != null) { route.excludes(excludes); } if (mapper != null) { route.map(mapper); } if (renderer != null) { route.renderer(renderer); } return route; } }