Search in sources :

Example 1 with Path

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;
}
Also used : Path(org.apache.knox.gateway.util.urltemplate.Path) Template(org.apache.knox.gateway.util.urltemplate.Template)

Example 2 with Path

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();
}
Also used : Path(org.apache.knox.gateway.util.urltemplate.Path)

Aggregations

Path (org.apache.knox.gateway.util.urltemplate.Path)2 Template (org.apache.knox.gateway.util.urltemplate.Template)1