3030import java .net .URI ;
3131import java .nio .charset .Charset ;
3232import java .security .KeyStore ;
33- import java .util .Date ;
33+ import java .util .ArrayList ;
34+ import java .util .Arrays ;
3435import java .util .LinkedHashMap ;
36+ import java .util .List ;
3537import java .util .Map ;
3638import java .util .concurrent .TimeUnit ;
3739
@@ -73,6 +75,7 @@ public static void main(final String[] args) throws Exception {
7375 String serverHost = "localhost" ;
7476 int serverPort = 8020 ;
7577 int secureServerPort = 0 ;
78+ List <String > customMappings = new ArrayList <>();
7679
7780 if (args .length > 0 ) {
7881 markLogicHost = args [0 ];
@@ -82,15 +85,18 @@ public static void main(final String[] args) throws Exception {
8285 serverPort = Integer .parseInt (args [2 ]);
8386 if (args .length > 3 ) {
8487 secureServerPort = Integer .parseInt (args [3 ]);
88+ if (args .length > 4 ) {
89+ customMappings = Arrays .asList (args [4 ].split ("," ));
90+ }
8591 }
8692 }
8793 }
8894 }
8995
90- new ReverseProxyServer (markLogicHost , serverHost , serverPort , secureServerPort );
96+ new ReverseProxyServer (markLogicHost , serverHost , serverPort , secureServerPort , customMappings );
9197 }
9298
93- public ReverseProxyServer (String markLogicHost , String serverHost , int serverPort , int secureServerPort ) throws Exception {
99+ public ReverseProxyServer (String markLogicHost , String serverHost , int serverPort , int secureServerPort , List < String > customMappings ) throws Exception {
94100 logger .info ("MarkLogic host: {}" , markLogicHost );
95101 logger .info ("Proxy server host: {}" , serverHost );
96102 logger .info ("Proxy server HTTP port: {}" , serverPort );
@@ -118,6 +124,10 @@ public ReverseProxyServer(String markLogicHost, String serverHost, int serverPor
118124 // these requests in a suitable fashion for manual testing.
119125 mapping .put ("/token" , new URI (String .format ("http://%s:8022" , serverHost )));
120126
127+ for (int i = 0 ; i < customMappings .size (); i += 2 ) {
128+ mapping .put (customMappings .get (i ), new URI (String .format ("http://%s:%s" , serverHost , customMappings .get (i + 1 ))));
129+ }
130+
121131 mapping .entrySet ().forEach (entry -> {
122132 logger .info ("Mapped: " + entry .getKey () + " : " + entry .getValue ());
123133 });
0 commit comments