use of io.micronaut.core.util.Toggleable in project micronaut-core by micronaut-projects.
the class DefaultHttpClientFilterResolver method resolveFilters.
@Override
public List<HttpClientFilter> resolveFilters(HttpRequest<?> request, List<FilterEntry<HttpClientFilter>> filterEntries) {
String requestPath = StringUtils.prependUri("/", request.getUri().getPath());
io.micronaut.http.HttpMethod method = request.getMethod();
List<HttpClientFilter> filterList = new ArrayList<>(filterEntries.size());
for (FilterEntry<HttpClientFilter> filterEntry : filterEntries) {
final HttpClientFilter filter = filterEntry.getFilter();
if (filter instanceof Toggleable && !((Toggleable) filter).isEnabled()) {
continue;
}
boolean matches = true;
if (filterEntry.hasMethods()) {
matches = anyMethodMatches(method, filterEntry.getFilterMethods());
}
if (filterEntry.hasPatterns()) {
matches = matches && anyPatternMatches(requestPath, filterEntry.getPatterns(), filterEntry.getPatternStyle());
}
if (matches) {
filterList.add(filter);
}
}
return filterList;
}
Aggregations