Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 2.44 KB

README_routing.md

File metadata and controls

61 lines (47 loc) · 2.44 KB

gateleen-routing

Schema validation

Updating the routing rules requires a validation against a schema to be positive. Check the schema gateleen_routing_schema_routing_rules

Request hop validation

To protect gateleen from routing rules configured to result in an endless loop, the request hop validation feature has been introduced.

Description

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

Usage

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
}

Log routing rule changes

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);