diff --git a/egress-router/pom.xml b/egress-router/pom.xml
index 772b34c411..8a755609e8 100644
--- a/egress-router/pom.xml
+++ b/egress-router/pom.xml
@@ -42,6 +42,10 @@
com.networknt
token-config
+
+ com.networknt
+ router-config
+
com.fasterxml.jackson.core
diff --git a/egress-router/src/main/java/com/networknt/router/middleware/PathPrefixServiceHandler.java b/egress-router/src/main/java/com/networknt/router/middleware/PathPrefixServiceHandler.java
index 7794c8598a..a9a9a95c6a 100644
--- a/egress-router/src/main/java/com/networknt/router/middleware/PathPrefixServiceHandler.java
+++ b/egress-router/src/main/java/com/networknt/router/middleware/PathPrefixServiceHandler.java
@@ -17,8 +17,9 @@
package com.networknt.router.middleware;
import com.networknt.config.Config;
+import com.networknt.handler.AuditAttachmentUtil;
import com.networknt.handler.Handler;
-import com.networknt.handler.HandlerUtils;
+import com.networknt.handler.config.HandlerUtils;
import com.networknt.handler.MiddlewareHandler;
import com.networknt.httpstring.HttpStringConstants;
import com.networknt.utility.Constants;
@@ -93,12 +94,12 @@ protected void pathPrefixService(HttpServerExchange exchange) throws Exception {
if (serviceEntry != null) {
if (logger.isTraceEnabled())
logger.trace("serviceEntry found and endpoint is set to = '{}@{}'", serviceEntry[0], exchange.getRequestMethod().toString().toLowerCase());
- HandlerUtils.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, serviceEntry[0] + "@" + exchange.getRequestMethod().toString().toLowerCase());
+ AuditAttachmentUtil.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, serviceEntry[0] + "@" + exchange.getRequestMethod().toString().toLowerCase());
} else {
if (logger.isTraceEnabled())
logger.trace("serviceEntry is null and endpoint is set to = '{}@{}'", Constants.UNKOWN_STRING, exchange.getRequestMethod().toString().toLowerCase());
// at this moment, we don't have a way to reliably determine the endpoint.
- HandlerUtils.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, Constants.UNKOWN_STRING + "@" + exchange.getRequestMethod().toString().toLowerCase());
+ AuditAttachmentUtil.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, Constants.UNKOWN_STRING + "@" + exchange.getRequestMethod().toString().toLowerCase());
}
}
diff --git a/egress-router/src/main/java/com/networknt/router/middleware/ServiceDictHandler.java b/egress-router/src/main/java/com/networknt/router/middleware/ServiceDictHandler.java
index 08014e146a..e3c5c73eba 100644
--- a/egress-router/src/main/java/com/networknt/router/middleware/ServiceDictHandler.java
+++ b/egress-router/src/main/java/com/networknt/router/middleware/ServiceDictHandler.java
@@ -1,10 +1,10 @@
package com.networknt.router.middleware;
import com.networknt.config.Config;
+import com.networknt.handler.AuditAttachmentUtil;
import com.networknt.handler.Handler;
-import com.networknt.handler.HandlerUtils;
+import com.networknt.handler.config.HandlerUtils;
import com.networknt.handler.MiddlewareHandler;
-import com.networknt.httpstring.AttachmentConstants;
import com.networknt.httpstring.HttpStringConstants;
import com.networknt.utility.Constants;
import com.networknt.utility.ModuleRegistry;
@@ -15,9 +15,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Find service Ids using a combination of path prefix and request method.
*
@@ -59,12 +56,12 @@ protected void serviceDict(HttpServerExchange exchange) throws Exception {
if (serviceEntry != null) {
if (logger.isTraceEnabled())
logger.trace("serviceEntry found and endpoint is set to = '{}'", serviceEntry[0]);
- HandlerUtils.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, serviceEntry[0]);
+ AuditAttachmentUtil.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, serviceEntry[0]);
} else {
if (logger.isTraceEnabled())
logger.trace("serviceEntry is null and endpoint is set to = '{}@{}'", Constants.UNKOWN_STRING, exchange.getRequestMethod().toString().toLowerCase());
// at this moment, we don't have a way to reliably determine the endpoint.
- HandlerUtils.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, Constants.UNKOWN_STRING + "@" + exchange.getRequestMethod().toString().toLowerCase());
+ AuditAttachmentUtil.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, Constants.UNKOWN_STRING + "@" + exchange.getRequestMethod().toString().toLowerCase());
}
}
diff --git a/handler/src/main/java/com/networknt/handler/HandlerUtils.java b/handler-config/src/main/java/com/networknt/handler/config/HandlerUtils.java
similarity index 68%
rename from handler/src/main/java/com/networknt/handler/HandlerUtils.java
rename to handler-config/src/main/java/com/networknt/handler/config/HandlerUtils.java
index 958d8bf411..d13004f9bc 100644
--- a/handler/src/main/java/com/networknt/handler/HandlerUtils.java
+++ b/handler-config/src/main/java/com/networknt/handler/config/HandlerUtils.java
@@ -1,17 +1,13 @@
-package com.networknt.handler;
+package com.networknt.handler.config;
-import com.networknt.httpstring.AttachmentConstants;
import com.networknt.utility.StringUtils;
-import io.undertow.server.HttpServerExchange;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
import java.util.Map;
public class HandlerUtils {
private static final Logger logger = LoggerFactory.getLogger(HandlerUtils.class);
- public static final String DELIMITOR = "@";
+ public static final String DELIMITER = "@";
protected static final String INTERNAL_KEY_FORMAT = "%s %s";
/**
@@ -57,7 +53,7 @@ public static String normalisePath(String requestPath) {
}
public static String toInternalKey(String key) {
- String[] tokens = StringUtils.trimToEmpty(key).split(DELIMITOR);
+ String[] tokens = StringUtils.trimToEmpty(key).split(DELIMITER);
if (tokens.length ==2) {
return toInternalKey(tokens[1], tokens[0]);
@@ -70,24 +66,4 @@ public static String toInternalKey(String key) {
public static String toInternalKey(String method, String path) {
return String.format(INTERNAL_KEY_FORMAT, method, HandlerUtils.normalisePath(path));
}
-
- public static void populateAuditAttachmentField(final HttpServerExchange exchange, String fieldName, String fieldValue) {
- Map auditInfo = exchange.getAttachment(AttachmentConstants.AUDIT_INFO);
-
- if(auditInfo == null) {
- logger.trace("AuditInfo is null, creating a new one and inserting the key-value pair '{}:{}'", fieldName, fieldValue);
- auditInfo = new HashMap<>();
- auditInfo.put(fieldName, fieldValue);
-
- } else {
- logger.trace("AuditInfo is not null, inserting the key-value pair '{}:{}'", fieldName, fieldValue);
-
- if (auditInfo.containsKey(fieldName))
- logger.debug("AuditInfo already contains the field '{}'! Replacing the value '{}' with '{}'.", fieldName, auditInfo.get(fieldName), fieldValue);
-
- auditInfo.put(fieldName, fieldValue);
- }
- exchange.putAttachment(AttachmentConstants.AUDIT_INFO, auditInfo);
- }
-
}
diff --git a/proxy-handler/src/main/java/com/networknt/handler/config/MethodRewriteRule.java b/handler-config/src/main/java/com/networknt/handler/config/MethodRewriteRule.java
similarity index 100%
rename from proxy-handler/src/main/java/com/networknt/handler/config/MethodRewriteRule.java
rename to handler-config/src/main/java/com/networknt/handler/config/MethodRewriteRule.java
diff --git a/proxy-handler/src/main/java/com/networknt/handler/config/QueryHeaderRewriteRule.java b/handler-config/src/main/java/com/networknt/handler/config/QueryHeaderRewriteRule.java
similarity index 100%
rename from proxy-handler/src/main/java/com/networknt/handler/config/QueryHeaderRewriteRule.java
rename to handler-config/src/main/java/com/networknt/handler/config/QueryHeaderRewriteRule.java
diff --git a/proxy-handler/src/main/java/com/networknt/handler/config/UrlRewriteRule.java b/handler-config/src/main/java/com/networknt/handler/config/UrlRewriteRule.java
similarity index 100%
rename from proxy-handler/src/main/java/com/networknt/handler/config/UrlRewriteRule.java
rename to handler-config/src/main/java/com/networknt/handler/config/UrlRewriteRule.java
diff --git a/handler/src/main/java/com/networknt/handler/AuditAttachmentUtil.java b/handler/src/main/java/com/networknt/handler/AuditAttachmentUtil.java
new file mode 100644
index 0000000000..8d5c059032
--- /dev/null
+++ b/handler/src/main/java/com/networknt/handler/AuditAttachmentUtil.java
@@ -0,0 +1,33 @@
+package com.networknt.handler;
+
+import com.networknt.httpstring.AttachmentConstants;
+import io.undertow.server.HttpServerExchange;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class AuditAttachmentUtil {
+ private static final Logger logger = LoggerFactory.getLogger(AuditAttachmentUtil.class);
+
+ public static void populateAuditAttachmentField(final HttpServerExchange exchange, String fieldName, String fieldValue) {
+ Map auditInfo = exchange.getAttachment(AttachmentConstants.AUDIT_INFO);
+
+ if(auditInfo == null) {
+ logger.trace("AuditInfo is null, creating a new one and inserting the key-value pair '{}:{}'", fieldName, fieldValue);
+ auditInfo = new HashMap<>();
+ auditInfo.put(fieldName, fieldValue);
+
+ } else {
+ logger.trace("AuditInfo is not null, inserting the key-value pair '{}:{}'", fieldName, fieldValue);
+
+ if (auditInfo.containsKey(fieldName))
+ logger.debug("AuditInfo already contains the field '{}'! Replacing the value '{}' with '{}'.", fieldName, auditInfo.get(fieldName), fieldValue);
+
+ auditInfo.put(fieldName, fieldValue);
+ }
+ exchange.putAttachment(AttachmentConstants.AUDIT_INFO, auditInfo);
+ }
+
+}
diff --git a/ingress-proxy/src/main/java/com/networknt/proxy/ExternalServiceHandler.java b/ingress-proxy/src/main/java/com/networknt/proxy/ExternalServiceHandler.java
index 69df50d5bd..67caa3a9ce 100644
--- a/ingress-proxy/src/main/java/com/networknt/proxy/ExternalServiceHandler.java
+++ b/ingress-proxy/src/main/java/com/networknt/proxy/ExternalServiceHandler.java
@@ -4,10 +4,7 @@
import com.networknt.client.Http2Client;
import com.networknt.client.ssl.TLSConfig;
import com.networknt.config.Config;
-import com.networknt.handler.BuffersUtils;
-import com.networknt.handler.Handler;
-import com.networknt.handler.HandlerUtils;
-import com.networknt.handler.MiddlewareHandler;
+import com.networknt.handler.*;
import com.networknt.handler.config.UrlRewriteRule;
import com.networknt.httpstring.AttachmentConstants;
import com.networknt.metrics.AbstractMetricsHandler;
@@ -119,7 +116,7 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
requestPath = exchange.getRequestPath();
}
- HandlerUtils.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, endpoint);
+ AuditAttachmentUtil.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, endpoint);
String method = exchange.getRequestMethod().toString();
String requestHost = parts[1];
String queryString = exchange.getQueryString();
diff --git a/ingress-proxy/src/main/java/com/networknt/proxy/mras/MrasHandler.java b/ingress-proxy/src/main/java/com/networknt/proxy/mras/MrasHandler.java
index 734b3d2d53..7215a4d7cd 100644
--- a/ingress-proxy/src/main/java/com/networknt/proxy/mras/MrasHandler.java
+++ b/ingress-proxy/src/main/java/com/networknt/proxy/mras/MrasHandler.java
@@ -8,13 +8,12 @@
import com.networknt.config.Config;
import com.networknt.config.JsonMapper;
import com.networknt.config.TlsUtil;
+import com.networknt.handler.AuditAttachmentUtil;
import com.networknt.handler.Handler;
-import com.networknt.handler.HandlerUtils;
import com.networknt.handler.MiddlewareHandler;
import com.networknt.handler.config.UrlRewriteRule;
import com.networknt.httpstring.AttachmentConstants;
import com.networknt.common.ContentType;
-import com.networknt.metrics.MetricsConfig;
import com.networknt.metrics.AbstractMetricsHandler;
import com.networknt.monad.Failure;
import com.networknt.monad.Result;
@@ -177,7 +176,7 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
}
// Audit log the endpoint info
- HandlerUtils.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, endpoint);
+ AuditAttachmentUtil.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, endpoint);
invokeApi(exchange, (String)config.getAccessToken().get(config.SERVICE_HOST), requestPath, "Bearer " + accessToken, startTime, endpoint);
if(logger.isDebugEnabled()) logger.debug("MrasHandler.handleRequest ends.");
diff --git a/ingress-proxy/src/main/java/com/networknt/proxy/salesforce/SalesforceHandler.java b/ingress-proxy/src/main/java/com/networknt/proxy/salesforce/SalesforceHandler.java
index a261bfdf62..632d280a63 100644
--- a/ingress-proxy/src/main/java/com/networknt/proxy/salesforce/SalesforceHandler.java
+++ b/ingress-proxy/src/main/java/com/networknt/proxy/salesforce/SalesforceHandler.java
@@ -7,12 +7,11 @@
import com.networknt.config.Config;
import com.networknt.config.JsonMapper;
import com.networknt.config.TlsUtil;
+import com.networknt.handler.AuditAttachmentUtil;
import com.networknt.handler.Handler;
-import com.networknt.handler.HandlerUtils;
import com.networknt.handler.MiddlewareHandler;
import com.networknt.handler.config.UrlRewriteRule;
import com.networknt.httpstring.AttachmentConstants;
-import com.networknt.metrics.MetricsConfig;
import com.networknt.metrics.AbstractMetricsHandler;
import com.networknt.monad.Failure;
import com.networknt.monad.Result;
@@ -377,7 +376,7 @@ private void invokeApi(HttpServerExchange exchange, String authorization, String
HttpRequest request = null;
// Audit log the endpoint info
- HandlerUtils.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, endpoint);
+ AuditAttachmentUtil.populateAuditAttachmentField(exchange, Constants.ENDPOINT_STRING, endpoint);
if(method.equalsIgnoreCase("GET")) {
request = HttpRequest.newBuilder()
diff --git a/pom.xml b/pom.xml
index ee2c7ec72c..ce38c17efc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -176,6 +176,7 @@
logger-handler
http-entity
token-config
+ router-config
egress-router
ingress-proxy
ruleloader-config
@@ -501,6 +502,11 @@
token-config
${project.version}
+
+ com.networknt
+ router-config
+ ${project.version}
+
com.networknt
egress-router
diff --git a/router-config/pom.xml b/router-config/pom.xml
new file mode 100644
index 0000000000..95ae522bf1
--- /dev/null
+++ b/router-config/pom.xml
@@ -0,0 +1,56 @@
+
+
+
+ light-4j
+ com.networknt
+ 2.1.34-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+ router-config
+ jar
+ A config module for egress-router shared with light-lambda-native.
+
+
+
+ com.networknt
+ config
+
+
+ com.networknt
+ utility
+
+
+ com.networknt
+ handler-config
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ com.networknt
+ service
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+ junit
+ junit
+ test
+
+
+
+
diff --git a/egress-router/src/main/java/com/networknt/router/HostWhitelist.java b/router-config/src/main/java/com/networknt/router/HostWhitelist.java
similarity index 100%
rename from egress-router/src/main/java/com/networknt/router/HostWhitelist.java
rename to router-config/src/main/java/com/networknt/router/HostWhitelist.java
diff --git a/egress-router/src/main/java/com/networknt/router/OAuthServerConfig.java b/router-config/src/main/java/com/networknt/router/OAuthServerConfig.java
similarity index 100%
rename from egress-router/src/main/java/com/networknt/router/OAuthServerConfig.java
rename to router-config/src/main/java/com/networknt/router/OAuthServerConfig.java
diff --git a/egress-router/src/main/java/com/networknt/router/RouterConfig.java b/router-config/src/main/java/com/networknt/router/RouterConfig.java
similarity index 100%
rename from egress-router/src/main/java/com/networknt/router/RouterConfig.java
rename to router-config/src/main/java/com/networknt/router/RouterConfig.java
diff --git a/egress-router/src/main/java/com/networknt/router/middleware/PathPrefixServiceConfig.java b/router-config/src/main/java/com/networknt/router/middleware/PathPrefixServiceConfig.java
similarity index 100%
rename from egress-router/src/main/java/com/networknt/router/middleware/PathPrefixServiceConfig.java
rename to router-config/src/main/java/com/networknt/router/middleware/PathPrefixServiceConfig.java
diff --git a/egress-router/src/main/java/com/networknt/router/middleware/PathServiceConfig.java b/router-config/src/main/java/com/networknt/router/middleware/PathServiceConfig.java
similarity index 100%
rename from egress-router/src/main/java/com/networknt/router/middleware/PathServiceConfig.java
rename to router-config/src/main/java/com/networknt/router/middleware/PathServiceConfig.java
diff --git a/egress-router/src/main/java/com/networknt/router/middleware/ServiceDictConfig.java b/router-config/src/main/java/com/networknt/router/middleware/ServiceDictConfig.java
similarity index 97%
rename from egress-router/src/main/java/com/networknt/router/middleware/ServiceDictConfig.java
rename to router-config/src/main/java/com/networknt/router/middleware/ServiceDictConfig.java
index 15ccae54e7..8857121860 100644
--- a/egress-router/src/main/java/com/networknt/router/middleware/ServiceDictConfig.java
+++ b/router-config/src/main/java/com/networknt/router/middleware/ServiceDictConfig.java
@@ -1,7 +1,8 @@
package com.networknt.router.middleware;
import com.networknt.config.Config;
-import com.networknt.handler.HandlerUtils;
+import com.networknt.handler.config.HandlerUtils;
+import com.networknt.utility.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/egress-router/src/main/resources/config/oauthServer.yml b/router-config/src/main/resources/config/oauthServer.yml
similarity index 100%
rename from egress-router/src/main/resources/config/oauthServer.yml
rename to router-config/src/main/resources/config/oauthServer.yml
diff --git a/egress-router/src/main/resources/config/pathPrefixService.yml b/router-config/src/main/resources/config/pathPrefixService.yml
similarity index 100%
rename from egress-router/src/main/resources/config/pathPrefixService.yml
rename to router-config/src/main/resources/config/pathPrefixService.yml
diff --git a/egress-router/src/main/resources/config/pathService.yml b/router-config/src/main/resources/config/pathService.yml
similarity index 100%
rename from egress-router/src/main/resources/config/pathService.yml
rename to router-config/src/main/resources/config/pathService.yml
diff --git a/egress-router/src/main/resources/config/router.yml b/router-config/src/main/resources/config/router.yml
similarity index 100%
rename from egress-router/src/main/resources/config/router.yml
rename to router-config/src/main/resources/config/router.yml
diff --git a/egress-router/src/main/resources/config/serviceDict.yml b/router-config/src/main/resources/config/serviceDict.yml
similarity index 100%
rename from egress-router/src/main/resources/config/serviceDict.yml
rename to router-config/src/main/resources/config/serviceDict.yml
diff --git a/egress-router/src/test/java/com/networknt/router/HostWhitelistTest.java b/router-config/src/test/java/com/networknt/router/HostWhitelistTest.java
similarity index 100%
rename from egress-router/src/test/java/com/networknt/router/HostWhitelistTest.java
rename to router-config/src/test/java/com/networknt/router/HostWhitelistTest.java
diff --git a/egress-router/src/test/java/com/networknt/router/RouterConfigTest.java b/router-config/src/test/java/com/networknt/router/RouterConfigTest.java
similarity index 100%
rename from egress-router/src/test/java/com/networknt/router/RouterConfigTest.java
rename to router-config/src/test/java/com/networknt/router/RouterConfigTest.java
diff --git a/egress-router/src/test/java/com/networknt/router/middleware/PathPrefixServiceConfigTest.java b/router-config/src/test/java/com/networknt/router/middleware/PathPrefixServiceConfigTest.java
similarity index 100%
rename from egress-router/src/test/java/com/networknt/router/middleware/PathPrefixServiceConfigTest.java
rename to router-config/src/test/java/com/networknt/router/middleware/PathPrefixServiceConfigTest.java
diff --git a/egress-router/src/test/java/com/networknt/router/middleware/PathServiceConfigTest.java b/router-config/src/test/java/com/networknt/router/middleware/PathServiceConfigTest.java
similarity index 100%
rename from egress-router/src/test/java/com/networknt/router/middleware/PathServiceConfigTest.java
rename to router-config/src/test/java/com/networknt/router/middleware/PathServiceConfigTest.java
diff --git a/egress-router/src/test/java/com/networknt/router/middleware/ServiceDictConfigTest.java b/router-config/src/test/java/com/networknt/router/middleware/ServiceDictConfigTest.java
similarity index 100%
rename from egress-router/src/test/java/com/networknt/router/middleware/ServiceDictConfigTest.java
rename to router-config/src/test/java/com/networknt/router/middleware/ServiceDictConfigTest.java
diff --git a/router-config/src/test/resources/config/router.yml b/router-config/src/test/resources/config/router.yml
new file mode 100644
index 0000000000..1e4652e828
--- /dev/null
+++ b/router-config/src/test/resources/config/router.yml
@@ -0,0 +1,80 @@
+---
+# Light Router Configuration
+# As this router is built to support discovery and security for light-4j services,
+# the outbound connection is always HTTP 2.0 with TLS enabled.
+# If HTTP 2.0 protocol will be accepted from incoming request.
+http2Enabled: false
+
+# If TLS is enabled when accepting incoming request. Should be true on test and prod.
+httpsEnabled: true
+
+# Max request time in milliseconds before timeout to the server.
+maxRequestTime: 1000
+
+# If a particular downstream service has different timeout than the above global definition, you can
+# add the path prefix and give it another timeout in millisecond. For downstream APIs not defined here,
+# they will use the global timeout defined in router.maxRequestTime.
+pathPrefixMaxRequestTime: ${router.pathPrefixMaxRequestTime:}
+
+# Connections per thread.
+connectionsPerThread: 10
+
+# The max queue size for the requests if there is no connection to the downstream API in the connection pool.
+# The default value is 0 that means there is queued requests. As we have maxConnectionRetries, there is no
+# need to use the request queue to increase the memory usage. It should only be used when you see 503 errors
+# in the log after maxConnectionRetries to accommodate slow backend API.
+maxQueueSize: ${router.maxQueueSize:0}
+
+# Soft max connections per thread.
+softMaxConnectionsPerThread: 5
+
+# Rewrite Host Header with the target host and port and write X_FORWARDED_HOST with original host
+rewriteHostHeader: true
+
+# Reuse XForwarded for the target XForwarded header
+reuseXForwarded: false
+
+# Max Connection Retries
+maxConnectionRetries: 3
+
+# allowed host list. Use Regex to do wildcard match
+hostWhitelist: ${router.hostWhitelist:}
+
+# support serviceId in the query parameter for routing to overwrite serviceId in header routing.
+# by default, it is false and should not be used unless you are dealing with a legacy client that
+# does not support header manipulation. Once this flag is true, we are going to overwrite the header
+# service_id derived with other handlers from prefix, path, endpoint etc.
+serviceIdQueryParameter: ${router.serviceIdQueryParameter:false}
+
+# URL rewrite rules, each line will have two parts: the regex patten and replace string separated
+# with a space. The light-router has service discovery for host routing, so whe working on the
+# url rewrite rules, we only need to create about the path in the URL.
+# Test your rules at https://www.freeformatter.com/java-regex-tester.html
+urlRewriteRules: ${router.urlRewriteRules:}
+
+# Method rewrite rules for legacy clients that do not support DELETE, PUT, and PATCH HTTP methods to
+# send a request with GET and POST instead. The gateway will rewrite the method from GET to DELETE or
+# from POST to PUT or PATCH. This will be set up at the endpoint level to limit the application.
+# The format of the rule will be "endpoint-pattern source-method target-method". Please refer to test
+# values.yml for examples. The endpoint-pattern is a pattern in OpenAPI specification. The following is
+# a list of examples:
+# /v1/pets/{petId} PATCH POST
+# /v1/pets PUT POST
+# Note: you cannot rewrite a method with a body to a method without a body or vice versa.
+methodRewriteRules: ${router.methodRewriteRules:}
+
+# Query parameter rewrite rules for client applications that send different query parameter keys or values
+# than the target server expecting. When overwriting a value, the key must be specified in order to
+# identify the right query parameter. If only the ok and nk are specified, the router will rewrite the
+# query parameter key ok with different key nk and keep the value.
+# The format of the rule will be a map with the path as the key. Please refer to test values.yml for
+# examples.
+queryParamRewriteRules: ${router.queryParamRewriteRules:}
+
+# Header rewrite rules for client applications that send different header keys or values than the target
+# server expecting. When overwriting a value, the key must be specified in order to identify the right
+# header. If only the ok and nk are specified, the router will rewrite the header key ok with different
+# key nk and keep the value.
+# The format of the rule will be a map with the path as the key. Please refer to test values.yml for
+# examples.
+headerRewriteRules: ${router.headerRewriteRules:}
diff --git a/router-config/src/test/resources/config/service.yml b/router-config/src/test/resources/config/service.yml
new file mode 100644
index 0000000000..b19739ca09
--- /dev/null
+++ b/router-config/src/test/resources/config/service.yml
@@ -0,0 +1,16 @@
+# Singleton service factory configuration/IoC injection
+singletons:
+- com.networknt.registry.URL:
+ - com.networknt.registry.URLImpl:
+ protocol: https
+ host: localhost
+ port: 8080
+ path: direct
+ parameters:
+ com.networknt.test-1.0.0: http://localhost:8082?environment=dev
+- com.networknt.registry.Registry:
+ - com.networknt.registry.support.DirectRegistry
+- com.networknt.balance.LoadBalance:
+ - com.networknt.balance.RoundRobinLoadBalance
+- com.networknt.cluster.Cluster:
+ - com.networknt.cluster.LightCluster
diff --git a/router-config/src/test/resources/config/values.yml b/router-config/src/test/resources/config/values.yml
new file mode 100644
index 0000000000..c7e630e4de
--- /dev/null
+++ b/router-config/src/test/resources/config/values.yml
@@ -0,0 +1,131 @@
+# router.hostWhitelist: "[\"192.168.0.*\",\"10.1.2.*\"]"
+router.hostWhitelist:
+ - 192.168.0.*
+ - 10.1.2.*
+
+# router.urlRewriteRules: "[\"/listings/(.*)$ /listing.html?listing=$1\",\"/ph/uat/de-asia-ekyc-service/v1 /uat-de-asia-ekyc-service/v1\",\"(/tutorial/.*)/wordpress/(\\\\w+)\\\\.?.*$ $1/cms/$2.php\"]"
+router.urlRewriteRules:
+ # test your regex rule at https://www.freeformatter.com/java-regex-tester.html#ad-output
+ # /listings/123 to /listing.html?listing=123
+ - /listings/(.*)$ /listing.html?listing=$1
+ # /ph/uat/de-asia-ekyc-service/v1 to /uat-de-asia-ekyc-service/v1
+ - /ph/uat/de-asia-ekyc-service/v1 /uat-de-asia-ekyc-service/v1
+ # /tutorial/linux/wordpress/file1 to /tutorial/linux/cms/file1.php
+ - (/tutorial/.*)/wordpress/(\w+)\.?.*$ $1/cms/$2.php
+
+# router.methodRewriteRules: "[\"/v2/address POST PUT\",\"/v1/address POST PATCH\",\"/v1/address GET DELETE\",\"/v1/pets/{petId} GET DELETE\"]"
+router.methodRewriteRules:
+ # rewrite POST to PUT for path /v2/address
+ - /v2/address POST PUT
+ # rewrite POST to PATCH for path /v1/address
+ - /v1/address POST PATCH
+ # rewrite GET to DELETE for path /v1/address
+ - /v1/address GET DELETE
+ # rewrite GET to DELETE for path /v1/pets/{petId} with path parameters
+ - /v1/pets/{petId} GET DELETE
+
+# router.queryParamRewriteRules: "{\"/v1/address\":[{\"oldK\":\"business-query\",\"newK\":\"request-query\",\"oldV\":\"value1\",\"newV\":\"value2\"},{\"oldK\":\"module\",\"newK\":\"mod\"},{\"oldK\":\"app-id\",\"oldV\":\"esb\",\"newV\":\"emb\"}],\"/v2/address\":[{\"oldK\":\"key1\",\"oldV\":\"old\",\"newV\":\"new\"}],\"/v3/address\":[{\"oldK\":\"path\",\"newK\":\"route\"}],\"/v1/pets/{petId}\":[{\"oldK\":\"path\",\"newK\":\"route\"}]}"
+router.queryParamRewriteRules:
+ # rewrite query parameter key business-query to request-query and value value1 to value2 for /v1/address
+ /v1/address:
+ - oldK: business-query
+ # overwrite the key
+ newK: request-query
+ oldV: value1
+ # overwrite the value at the same time.
+ newV: value2
+ - oldK: module
+ newK: mod
+ - oldK: app-id
+ oldV: esb
+ newV: emb
+ # rewrite query parameter value from old to new for key key1 for /v2/address
+ /v2/address:
+ # key must be here when you want to overwrite a value.
+ - oldK: key1
+ # only the value = old then we change to new.
+ oldV: old
+ newV: new
+ # rewrite query parameter key from path to route for /v3/address
+ /v3/address:
+ - oldK: path
+ newK: route
+ # using path parameters
+ /v1/pets/{petId}:
+ - oldK: path
+ newK: route
+
+# router.headerRewriteRules: "{\"/v1/address\":[{\"oldK\":\"business-query\",\"newK\":\"request-query\",\"oldV\":\"value1\",\"newV\":\"value2\"},{\"oldK\":\"module\",\"newK\":\"mod\"},{\"oldK\":\"app-id\",\"oldV\":\"esb\",\"newV\":\"emb\"}],\"/v2/address\":[{\"oldK\":\"key1\",\"oldV\":\"old\",\"newV\":\"new\"}],\"/v3/address\":[{\"oldK\":\"path\",\"newK\":\"route\"}],\"/v1/pets/{petId}\":[{\"oldK\":\"path\",\"newK\":\"route\"}]}"
+router.headerRewriteRules:
+ # rewrite header key business-query to request-query and value value1 to value2 for /v1/address
+ /v1/address:
+ - oldK: business-query
+ # overwrite the key
+ newK: request-query
+ oldV: value1
+ # overwrite the value at the same time.
+ newV: value2
+ - oldK: module
+ newK: mod
+ - oldK: app-id
+ oldV: esb
+ newV: emb
+ # rewrite header value from old to new for key key1 for /v2/address
+ /v2/address:
+ # key must be here when you want to overwrite a value.
+ - oldK: key1
+ # only the value = old then we change to new.
+ oldV: old
+ newV: new
+ # rewrite header key from path to route for /v3/address
+ /v3/address:
+ - oldK: path
+ newK: route
+ # rewrite header key from path to route for /v1/pets/{petId}
+ /v1/pets/{petId}:
+ - oldK: path
+ newK: route
+
+# set the timeout per path for test cases
+#router.pathPrefixMaxRequestTime:
+# /v1/address: 5000
+# /v2/address: 10000
+# /v3/address: 30000
+router.pathPrefixMaxRequestTime: "{\"/v1/address\":5000,\"/v2/address\":10000,\"/v3/address\":30000,\"/v1/pets/{petId}\": 5000}"
+# router.pathPrefixMaxRequestTime: {"/v1/address":5000,"/v2/address":10000,"/v3/address":30000,"/v1/pets/{petId}": 5000}
+
+# client.yml
+# test configuration for the TokenHandler with multiple OAuth 2.0 providers.
+client.multipleAuthServers: true
+client.tokenCcServiceIdAuthServers:
+ service1:
+ server_url: https://localhost:7771
+ enableHttp2: true
+ uri: /oauth1/token
+ client_id: f7d42348-c647-4efb-a52d-4c5787421e72
+ client_secret: f6h1FTI8Q3-7UScPZDzfXA
+ scope:
+ - petstore.r
+ - petstore.w
+ service2:
+ server_url: https://localhost:7772
+ enableHttp2: true
+ uri: /oauth2/token
+ client_id: f7d42348-c647-4efb-a52d-4c5787421e73
+ client_secret: f6h1FTI8Q3-7UScPZDzfXA
+ scope:
+ - market.r
+ - market.w
+
+# pathPrefixService.yml
+# pathPrefixService.mapping: /v1/address=party.address-1.0.0&/v2/address=party.address-2.0.0&/v1/contact=party.contact-1.0.0
+pathPrefixService.mapping: {"/v1/address": "party.address-1.0.0", "/v2/address": "party.address-2.0.0", "/v1/contact": "party.contact-1.0.0"}
+
+# pathService.yml
+# pathService.mapping: /v1/address/{id}@get=party.address-1.0.0&/v2/address@get=party.address-2.0.0&/v1/contact@post=party.contact-1.0.0
+
+# serviceDict.yml
+# serviceDict.mapping: /v1/address@get=party.address-1.0.0&/v2/address@get=party.address-2.0.0&/v1/contact@post=party.contact-1.0.0
+
+# oauthServer.yml
+oauthServer.client_credentials: test1:test1pass,test2:test2pass