-
Notifications
You must be signed in to change notification settings - Fork 4
/
hello2.rpgle
42 lines (29 loc) · 1.26 KB
/
hello2.rpgle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<%@ language="RPGLE" free="true" %>
<%
ctl-opt copyright('System & Method (C), 2019');
ctl-opt decEdit('0,') datEdit(*YMD.) main(sayHello);
/* -----------------------------------------------------------------------------
CRTICEPGM STMF('/www/IceBreak-Samples/hello2.rpgle') SVRID(samples)
Send greetings as a JSON object
Showcase:
Block comment : https://ibm-power-systems-cc.ideas.ibm.com/ideas/IBMI-I-1577
String templates: https://ibm-power-systems-cc.ideas.ibm.com/ideas/IBMI-I-1525
http://sandbox.icebreak.org:60060/hello2.rpgle?message=My%20name%20is%20John
http://my_ibm_i:60060/hello2.rpgle?message=My%20name%20is%20John
\* -------------------------------------------------------------------- */
dcl-proc sayHello;
dcl-s message varchar(256);
dcl-s res varchar(4096);
// Get the data from the URL
message = reqStr('message');
// Send the response back to client in JSON format
// Here we use the template engine - note back qote ` and the ${ ..rpg.. }
// Usefull - but not recomended. Rather use noxDb JSON feature ( it is build in)
setContentType('application/json;charset=utf-8');
res = strFormat (`
{
"text" : "Hello world. ${ message }, time is ${ %char(%timestamp()) }"
}
`);
responseWrite(res);
end-proc;