use of io.gravitee.gateway.handlers.api.path.Path in project gravitee-gateway by gravitee-io.
the class ApiPolicyChainResolver method calculate.
@Override
protected List<Policy> calculate(StreamType streamType, Request request, Response response, ExecutionContext executionContext) {
// Resolve the "configured" path according to the inbound request
Path path = pathResolver.resolve(request.path());
executionContext.setAttribute(ExecutionContext.ATTR_RESOLVED_PATH, path.getResolvedPath());
return path.getRules().stream().filter(rule -> rule.isEnabled() && rule.getMethods().contains(request.method())).map(rule -> create(streamType, rule.getPolicy().getName(), rule.getPolicy().getConfiguration())).filter(Objects::nonNull).collect(Collectors.toList());
}
use of io.gravitee.gateway.handlers.api.path.Path in project gravitee-gateway by gravitee-io.
the class AbstractPathResolver method resolve.
@Override
public Path resolve(final String path) {
String decodedPath;
try {
decodedPath = URLDecoder.decode(path, DEFAULT_CHARSET);
} catch (UnsupportedEncodingException uee) {
decodedPath = path;
}
decodedPath += '/';
int pieces = -1;
Path bestPath = null;
for (Path registerPath : registeredPaths) {
if (registerPath.getPattern().matcher(decodedPath).lookingAt()) {
int split = registerPath.getPath().split(URL_PATH_SEPARATOR).length;
if (split > pieces) {
pieces = split;
bestPath = registerPath;
}
}
}
return bestPath;
}
Aggregations