-
Notifications
You must be signed in to change notification settings - Fork 1
/
router.js
33 lines (27 loc) · 1017 Bytes
/
router.js
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
var hm = require('header-metadata');
var service = require('service-metadata');
//Read input
session.input.readAsBuffers(function (error, input) {
if (error) {
// handle error
session.output.write (error.errorMessage);
}
else {
if (input == '') {
session.output.write("Please enter name, accounts, or beneficiaries.");
service.mpgw.skipBackside = true;
}
//If input contains "name", route traffic to /profile endpoint.
if (input.indexOf('name') > -1) {
service.setVar('var://service/routing-url', 'http://localhost:2000/profile');
}
//If input contains "accounts", route traffic to /accounts endpoint.
if (input.indexOf('accounts') > -1) {
service.setVar('var://service/routing-url', 'http://localhost:2000/accounts');
}
//If input contains "beneficiaries", route traffic to /beneficiaries endpoint.
if (input.indexOf('beneficiaries') > -1) {
service.setVar('var://service/routing-url', 'http://localhost:2000/beneficiaries');
}
}
});