Forum Discussion
regex irule without payload change
I would use iRules LX for anything JSON related. Take a look at my code share on replacing JSON objects for some ideas (https://community.f5.com/t5/codeshare/simple-iruleslx-json-rewrite/ta-p/289095),
You can write a very simple version just to return the username and IP address as list back to TCL.
Take the following JSON data:
{
"username":"Jason",
"ip":"192.168.1.1"
}
You can pass the JSON payload to iRules LX an return the values based on the keys that you pass in.
So you could pass in the payload, 'username' and 'ip' to iRules LX
set result [ILX::call $rpcHandle "myMethod" [HTTP::payload] "username" "ip"]
From there you can write a very simple script to return the values:
const f5 = require('f5-nodejs');
const ilx = new f5.ILXServer();
function myMethod(req, res) {
var json = JSON.parse(req.params()[0]);
var jsonUser = req.params()[1];
var jsonIp = req.params()[2];
var user = json[jsonUser];
var ip = json[jsonIp];
res.reply(user + ' ' + ip);
}
ilx.addMethod('myMethod', myMethod);
ilx.listen();
This will return username and ip which TCL can interpret as a list e.g
set username [lindex $result 0]
set ip [lindex $result 1]
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com