use of org.apache.knox.gateway.util.urltemplate.Template 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.Template in project knox by apache.
the class ServiceSchemeFunctionProcessor 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 && !url.equals(parameter)) {
Template template = Parser.parseLiteral(url);
Scheme scheme = template.getScheme();
if (scheme != null) {
parameter = scheme.getFirstValue().getPattern();
}
}
results.add(parameter);
}
}
return results;
}
use of org.apache.knox.gateway.util.urltemplate.Template in project knox by apache.
the class UrlRewriteActionRewriteProcessorExt method process.
@Override
public UrlRewriteStepStatus process(UrlRewriteContext context) throws Exception {
Template rewritten = expander.expandToTemplate(template, context.getParameters(), context.getEvaluator());
context.setCurrentUrl(rewritten);
return UrlRewriteStepStatus.SUCCESS;
}
use of org.apache.knox.gateway.util.urltemplate.Template in project knox by apache.
the class JavaScriptUrlRewriteFilterReader method filterValueString.
@Override
public String filterValueString(String name, String value, String rule) {
try {
Template input = Parser.parseLiteral(value);
Template output = rewriter.rewrite(resolver, input, direction, rule);
if (output != null) {
value = output.getPattern();
}
} catch (URISyntaxException e) {
LOG.failedToParseValueForUrlRewrite(value);
}
return value;
}
use of org.apache.knox.gateway.util.urltemplate.Template in project knox by apache.
the class JsonUrlRewriteFilterReader method filterValueString.
protected String filterValueString(String name, String value, String rule) {
try {
Template input = Parser.parseLiteral(value);
Template output = rewriter.rewrite(resolver, input, direction, rule);
value = output.getPattern();
} catch (URISyntaxException e) {
LOG.failedToParseValueForUrlRewrite(value);
}
return value;
}
Aggregations