Difference between revisions of "I2Rest Gate URL definition using Unix socket"
Pavel.lobko (talk | contribs) |
Pavel.lobko (talk | contribs) |
||
Line 1: | Line 1: | ||
− | + | [[I2Rest_Gates#i2Rest_Gates|i2Rest Server Gates]] are able to listen incoming requests at some unix socket defined as a file at IFS. In this case, the server gate will not be accessible externally, so your i2Rest Server instance and its clients both should be located on the same IBM i server. As an example of such a case - [[I2Rest_anonymous_sessions|Anonymous session]] (which is an IBM i job serving request to ECHO test program), and i2Rest Session Gate (which is the internal endpoint requested by submited sessions).<br> | |
− | + | In the basic configuration "session" is defined by default - when i2Rest Server can't find configuration for some gate, it creates temporary unix socket endpoint at /tmp folder, for example /tmp/AS5WRD7DCJ. Configuration bellow shows how to define I2Rest Gate URL using Unix socket explicitly. | |
;Step 1 | ;Step 1 | ||
:Create text file named I2RESTECHO.PCML anywhere on IFS, for example "/tmp/PCML/i2restecho.pcml". Copy and paste following code. It represents a description for the sample program I2RESTECHO, that is included into i2Rest Server installation for demonstration purposes: | :Create text file named I2RESTECHO.PCML anywhere on IFS, for example "/tmp/PCML/i2restecho.pcml". Copy and paste following code. It represents a description for the sample program I2RESTECHO, that is included into i2Rest Server installation for demonstration purposes: | ||
Line 22: | Line 22: | ||
"main" : {"url":"http://<span style="color:red;"><host_name>[:port] (for example api.i2rest.com:1234)</span>"}, | "main" : {"url":"http://<span style="color:red;"><host_name>[:port] (for example api.i2rest.com:1234)</span>"}, | ||
"management" : {"url":"http://<span style="color:red;"><host_name>[:port] (for example api.i2rest.com:4321)</span>"}, | "management" : {"url":"http://<span style="color:red;"><host_name>[:port] (for example api.i2rest.com:4321)</span>"}, | ||
− | <span style="background:#00FFFF;">"session" : {file://<span style="color:red;"><IFS file>(for example i2Rest/Session)</span>", "dcm_server_id":"<span style="color:red;"><dcm server id>(for example MYSERVER)</span>"}</span> | + | <span style="background:#00FFFF;">"session" : {"url":"file://<span style="color:red;"><IFS file>(for example /i2Rest/Session)</span>", "dcm_server_id":"<span style="color:red;"><dcm server id>(for example MYSERVER)</span>"}</span> |
}, | }, | ||
"session_systems": | "session_systems": |
Revision as of 14:32, 30 June 2020
i2Rest Server Gates are able to listen incoming requests at some unix socket defined as a file at IFS. In this case, the server gate will not be accessible externally, so your i2Rest Server instance and its clients both should be located on the same IBM i server. As an example of such a case - Anonymous session (which is an IBM i job serving request to ECHO test program), and i2Rest Session Gate (which is the internal endpoint requested by submited sessions).
In the basic configuration "session" is defined by default - when i2Rest Server can't find configuration for some gate, it creates temporary unix socket endpoint at /tmp folder, for example /tmp/AS5WRD7DCJ. Configuration bellow shows how to define I2Rest Gate URL using Unix socket explicitly.
- Step 1
- Create text file named I2RESTECHO.PCML anywhere on IFS, for example "/tmp/PCML/i2restecho.pcml". Copy and paste following code. It represents a description for the sample program I2RESTECHO, that is included into i2Rest Server installation for demonstration purposes:
<pcml version="1.0"> <program name="echo" path="/QSYS.LIB/%LIBL%.LIB/I2RESTECHO.PGM"> <data name="echo" usage="inputoutput" type="char" length="10" trim="both"/> </program> </pcml>
- Step 2
- Contact your system administrator for your IBM i server host name (or IP) and two available ports for "main" and "management" gates of your first i2Rest Server instance. Create file config.json (you can name it with any name and put it into any available IFS folder). Enter following text, replace host_name, ports and pcml_file with appropriate values.
Basic configuration with Unix socket defined gate (differences are highlighted in blue):
{ "gates": { "main" : {"url":"http://<host_name>[:port] (for example api.i2rest.com:1234)"}, "management" : {"url":"http://<host_name>[:port] (for example api.i2rest.com:4321)"}, "session" : {"url":"file://<IFS file>(for example /i2Rest/Session)", "dcm_server_id":"<dcm server id>(for example MYSERVER)"} }, "session_systems": [ { "name" : "*ANONYMOUS", "submit" : "SBMJOB JOB(I2RESTA) \ USER(${user}) \ CMD(CALL I2REST \ PARM('-session' \ '-url' '${surl}' \ '-uid' '${uid}' \ '-user' '${user}')) \ INLLIBL(I2REST)" } ], "pcmls": [ { "pcml_mount" : "echo", "pcml_file" : "<complete name of i2restecho.pcml on IFS (for example /tmp/PCML/i2restecho.pcml)>", "valid_in_anonymous" : true } ] }