Adding a Base Configuration File
The entry point for requests coming in to IG is a JSON-encoded configuration file, expected by default at:
$HOME/.openig/config/config.json
%appdata%\OpenIG\config\config.json
The base configuration file initializes a heap of objects and provides the main handler to receive incoming requests. Configuration in the file is inherited by all applicable objects in the configuration.
At startup, if IG doesn't find a base configuration file, it provides a default version, given in "Default Configuration". The default looks for routes in:
$HOME/.openig/config/routes
%appdata%\OpenIG\config\routes
Consider adding a custom config.json
for these reasons:
To prevent using the default
config.json
, whose configuration might not be appropriate in your deployment.To define an object once in
config.json
, and then use it multiple times in your configuration.
After adding or editing config.json
, stop and restart IG to take the changes into effect.
For more information, see "GatewayHttpApplication (config.json
)", "Heap Objects", and "Router".
Add the following file to IG:
$HOME/.openig/config/config.json
%appdata%\OpenIG\config\config.json
{ "handler": { "type": "Router", "name": "_router", "baseURI": "http://app.example.com:8081", "capture": "all" }, "heap": [ { "name": "JwtSession", "type": "JwtSession" }, { "name": "capture", "type": "CaptureDecorator", "config": { "captureEntity": true, "_captureContext": true } } ] }
Notice the following features of the file:
The handler contains a main router named
_router
. When IG receives an incoming request,_router
routes the request to the first route in the configuration whose condition is satisfied.The
baseURI
changes the request URI to point the request to the sample application.The
capture
captures the body of the HTTP request and response.The JwtSession object in the heap can be used in routes to store the session information as JSON Web Tokens (JWT) in a cookie. For more information, see "JwtSession".
Stop and restart IG.
Check that the route system log includes a message that the file is loaded into the config:
INFO o.f.openig.web.Initializer - Reading the configuration from ...config.json