in gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessor.java [70:106]
public String resolve( UrlRewriter.Direction direction, String parameter ) throws Exception {
String addr = parameter;
String url = lookupServiceUrl( parameter );
if( url != null ) {
Template template = Parser.parseLiteral( url );
Host host = template.getHost();
String hostStr = null;
if( host != null ) {
hostStr = host.getFirstValue().getPattern();
if( hostmap != null ) {
switch( direction ) {
case IN:
hostStr = hostmap.resolveInboundHostName( hostStr );
break;
case OUT:
hostStr = hostmap.resolveOutboundHostName( hostStr );
break;
}
}
}
Port port = template.getPort();
String portStr = null;
if( port != null ) {
portStr = port.getFirstValue().getPattern();
}
if( hostStr != null && portStr != null ) {
addr = hostStr + ":" + portStr;
} else if( host != null && port == null ) {
addr = hostStr;
} else if( host == null && port != null ) {
addr = ":" + portStr;
}
}
return addr;
}