use of org.apache.knox.gateway.util.urltemplate.Path in project knox by apache.
the class ServicePathFunctionProcessor method resolve.
@Override
public List<String> resolve(UrlRewriteContext context, List<String> parameters) throws Exception {
List<String> results = null;
if (parameters != null) {
results = new ArrayList<String>(parameters.size());
for (String parameter : parameters) {
String url = lookupServiceUrl(parameter);
if (url != null) {
Template template = Parser.parseLiteral(url);
List<Path> path = template.getPath();
if (path != null) {
parameter = toString(path);
}
}
results.add(parameter);
}
}
return results;
}
use of org.apache.knox.gateway.util.urltemplate.Path in project knox by apache.
the class ServicePathFunctionProcessor method toString.
private String toString(List<Path> paths) {
StringBuilder s = new StringBuilder();
for (Path path : paths) {
s.append('/');
s.append(path.getFirstValue().getPattern());
}
if (s.length() == 0) {
s.append('/');
}
return s.toString();
}