Updating the routing rules requires a validation against a schema to be positive. Check the schema gateleen_routing_schema_routing_rules
To protect gateleen from routing rules configured to result in an endless loop, the request hop validation feature has been introduced.
When the request hop validation is activated, a x-hops request header will be added to the request before routing. Initially, this header will receive the value 1. When the x-hops header already exists (in alredy routed requests for example), the value will be increased by 1.
Before the request is routed, the x-hops header value will be checked against a configurable limit. When the limit is exceeded, the request will be answered with a http status code 500 and a http status message: Request hops limit exceeded
To use the request hop validation feature, the ConfigurationResourceManager and the path to the configuration resource have to be configured in the Router by calling:
router.enableRoutingConfiguration(configurationResourceManager, SERVER_ROOT + "/admin/v1/routing/config")
The routing configuration is a json resource defining the limit for the maximum request routings (hops) called request.hops.limit.
Example:
{
"request.hops.limit": 10
}
To log the payload of changes to the routing rules, the RequestLogger can be used.
Make sure to instantiate the RequestLoggingConsumer by calling
RequestLoggingConsumer requestLoggingConsumer = new RequestLoggingConsumer(vertx, loggingResourceManager);
To enable the logging of the routing rules, make sure the url to the routing rules is enabled in the logging resource.
Example:
{
"headers": [],
"payload": {
"filters": [
{
"url": "/playground/server/admin/v1/routing/.*",
"method": "PUT"
}
]
}
}
Also you have to enable the logging on the Router by calling
router.enableResourceLogging(true);