Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ task runBlockingReverseProxyServer(type: JavaExec) {
"sudo ./gradlew runBlockingReverseProxyServer -PrpsHttpsPort=443 ."
classpath = sourceSets.main.runtimeClasspath
main = "com.marklogic.client.test.ReverseProxyServer"
args = [rpsMarkLogicServer, rpsProxyServer, rpsHttpPort, rpsHttpsPort]
args = [rpsMarkLogicServer, rpsProxyServer, rpsHttpPort, rpsHttpsPort, rpsCustomMappings]
}
3 changes: 3 additions & 0 deletions test-app/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ rpsMarkLogicServer=localhost
rpsProxyServer=localhost
rpsHttpPort=8020
rpsHttpsPort=0
# Comma-delimited sequence of path1,port1,path2,port2,etc
# Example: rpsCustomMappings=/my/server,8005,/my/other/server,9090
rpsCustomMappings=
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import java.net.URI;
import java.nio.charset.Charset;
import java.security.KeyStore;
import java.util.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -73,6 +75,7 @@ public static void main(final String[] args) throws Exception {
String serverHost = "localhost";
int serverPort = 8020;
int secureServerPort = 0;
List<String> customMappings = new ArrayList<>();

if (args.length > 0) {
markLogicHost = args[0];
Expand All @@ -82,15 +85,18 @@ public static void main(final String[] args) throws Exception {
serverPort = Integer.parseInt(args[2]);
if (args.length > 3) {
secureServerPort = Integer.parseInt(args[3]);
if (args.length > 4) {
customMappings = Arrays.asList(args[4].split(","));
}
}
}
}
}

new ReverseProxyServer(markLogicHost, serverHost, serverPort, secureServerPort);
new ReverseProxyServer(markLogicHost, serverHost, serverPort, secureServerPort, customMappings);
}

public ReverseProxyServer(String markLogicHost, String serverHost, int serverPort, int secureServerPort) throws Exception {
public ReverseProxyServer(String markLogicHost, String serverHost, int serverPort, int secureServerPort, List<String> customMappings) throws Exception {
logger.info("MarkLogic host: {}", markLogicHost);
logger.info("Proxy server host: {}", serverHost);
logger.info("Proxy server HTTP port: {}", serverPort);
Expand Down Expand Up @@ -118,6 +124,10 @@ public ReverseProxyServer(String markLogicHost, String serverHost, int serverPor
// these requests in a suitable fashion for manual testing.
mapping.put("/token", new URI(String.format("http://%s:8022", serverHost)));

for (int i = 0; i < customMappings.size(); i += 2) {
mapping.put(customMappings.get(i), new URI(String.format("http://%s:%s", serverHost, customMappings.get(i + 1))));
}

mapping.entrySet().forEach(entry -> {
logger.info("Mapped: " + entry.getKey() + " : " + entry.getValue());
});
Expand Down