Route
Routes are configuration files that you add to IG to manage requests. They are flat files in JSON format. You can add routes in the following ways:
-
Manually into the filesystem.
-
Through Common REST commands. For information, see Create and Edit Routes Through Common REST.
-
Through Studio. For information, see the Studio Guide.
Every route must call a handler to process requests and produce responses to requests.
When a route has a condition, it can handle only requests that meet the condition. When a route has no condition, it can handle any request.
Routes inherit settings from their parent configuration. This means that you
can configure global objects in the config.json
heap, for example,
and then reference the objects by name in any other IG configuration.
For examples of route configurations see Configure Routers and Routes.
Usage
{
"handler": Handler reference or inline Handler declaration,
"heap": [ configuration object, ... ],
"condition": runtime expression<boolean>,
"name": string,
"secrets": configuration object,
"session": JwtSession object,
"auditService": AuditService object,
"globalDecorators": configuration object,
"decorator name": decorator configuration object
}
Properties
"handler"
: Handler reference, required-
For this route, dispatch the request to this handler.
Provide either the name of a Handler object defined in the heap, or an inline Handler configuration object.
See also Handlers.
"heap"
: array of configuration objects, optional-
Heap object configuration for objects local to this route.
Objects referenced but not defined here are inherited from the parent.
You can omit an empty array. If you only have one object in the heap, you can inline it as the handler value.
See also Heap Objects.
"condition"
: runtime expression<boolean>, optional-
An inline expression to define a condition based on the request, context, or IG runtime environment, such as system properties or environment variables.
Conditions are defined using IG expressions, as described in Expressions, and are evaluated as follows:
-
If the condition evaluates to
true
, the request is dispatched to the route. -
If the condition evaluates to
false
, the condition for the next route in the configuration is evaluated. -
If no condition is specified, the request is dispatched unconditionally to the route.
For debugging, log the routes for which IG evaluates a condition, and the route that matches a condition. Add the following line to a custom
$HOME/.openig/config/logback.xml
, and restart IG:<logger name="org.forgerock.openig.handler.router.RouterHandler" level="trace" />
For information, see Managing Logs.
For example conditions and requests that match them, see Example Conditions and Requests.
An external request can never match a condition that uses the reserved administrative route. Therefore, routes that use these conditions are effectively ignored. For example, if
/openig
is the administrative route, a route with the following condition is ignored:${matches(request.uri.path, '^/openig/my/path')}
.Default: No condition is specified.
-
"name"
: string, optional-
Name for the route.
The Router uses the
name
property to order the routes in the configuration. If the route does not have aname
property, the Router uses the route ID.The route ID is managed as follows:
-
When you add a route manually to the routes folder, the route ID is the value of the
_id
field. If there is no_id
field, the route ID is the filename of the added route. -
When you add a route through the Common REST endpoint, the route ID is the value of the mandatory
_id
field. -
When you add a route through Studio, you can edit the default route ID.
CAUTION: The filename of a route cannot be
default.json
. The routename
property or route ID cannot bedefault
.
Default: route ID
-
"secrets"
: configuration object, optional-
An object that configures an inline array of one or more secret stores, as defined in Default Secrets Object.
"session"
: JwtSession object, optional-
Stateless session implementation for this route. Define a JwtSession object inline or in the heap.
When a request enters the route, IG builds a new session object for the route. The session content is available to the route’s downstream handlers and filters. Session content available in the ascending configuration (a parent route or
config.json
) is not available in the new session.When the response exits the route, the session content is serialized as a secure JWT that is encrypted and signed, and the resulting JWT string is placed in a cookie. Session information set inside the route is no longer available. The
session
references the previous session object.Default: Do not change the session storage implementation.
For more information, see JwtSession, and Sessions.
"auditService"
: AuditService object, optional-
Provide an audit service for the route. Provide either the name of an AuditService object defined in the heap, or an inline AuditService configuration object.
Default: No auditing of a configuration. The NoOpAuditService provides an empty audit service to the top-level heap and its child routes.
"globalDecorators"
: one or more decorations, optional-
Decorate all compatible objects in the route with one or more decorators referred to by the decorator name, and provide the configuration as described in Decorators:
"globalDecorators": { "decorator name": decoration configuration ... }
The following object decorates all compatible objects in the route with a capture and timer decorator:
"globalDecorators": { "capture": "all", "timer": true }
Default: No decoration.
"decorator name"
: decoration, optional-
Decorate the main handler of this route with a decorator referred to by the decorator name, and provide the configuration as described in Decorators.
Default: No decoration.
Route Metrics at the Prometheus Scrape Endpoint
Route metrics at the Prometheus Scrape Endpoint have the following labels:
-
name
: Route name, for example,My Route
.If the router was declared with a default handler, then its metrics are published through the route named
default
. -
route
: Route identifier, for example,my-route
. -
router
: Fully qualified name of the router, for example,gateway.main-router
.
The following table summarizes the recorded metrics:
Name | Monitoring Type | Description |
---|---|---|
|
Gauge |
Number of requests being processed. |
|
Counter |
Number of requests processed by the router or route since it was deployed. |
|
Counter |
Number of responses that threw an exception. |
|
Counter |
Number of responses that were not handled by IG. |
|
Counter |
Number of responses by HTTP status code family. The
|
|
Summary |
A summary of response time observations. |
For more information about the the Prometheus Scrape Endpoint, see Prometheus Scrape Endpoint.
Route Metrics at the Common REST Monitoring Endpoint
Route metrics at the Common REST Monitoring Endpoint are published with an _id
in the
following pattern:
-
heap.router-name.route.route-name.metric
The following table summarizes the recorded metrics:
Name | Monitoring Type | Description |
---|---|---|
|
Counter |
Number of requests processed by the router or route since it was deployed. |
|
Gauge |
Number of requests being processed by the router or route at this moment. |
|
Counter |
Number of responses that threw an exception. |
|
Counter |
Number of responses that were not handled by IG. |
|
Counter |
Number of responses with an HTTP status code |
|
Counter |
Number of responses with an HTTP status code |
|
Counter |
Number of responses with an HTTP status code |
|
Counter |
Number of responses with an HTTP status code |
|
Counter |
Number of responses with an HTTP status code |
|
Counter |
Number of responses with an HTTP status code |
|
Timer |
Time-series summary statistics. |
For more information about the the Common REST Monitoring Endpoint, see Common REST Monitoring Endpoint.