Forum Discussion
Using a Data-Group string values in 11 code, can you match in both directions?
- Jul 26, 2016
Not without iterating through each element. A data-group is like an associative array (aka map, aka dictionary). In other words, it's a set of key/value pairs, where lookups are by key, not value. If you want to perform such a lookup, you should duplicate in your data-group each entry with the key and value reversed. Naturally, the keys must be unique, so if the same value exists for more than one key, then it won't work.
In case you care, the iteration would be like this:
when HTTP_REQUEST { foreach kv [class get dg-your-data-group] { log local0. "key = [lindex $kv 0], value = [lindex $kv 1]" } }
Not without iterating through each element. A data-group is like an associative array (aka map, aka dictionary). In other words, it's a set of key/value pairs, where lookups are by key, not value. If you want to perform such a lookup, you should duplicate in your data-group each entry with the key and value reversed. Naturally, the keys must be unique, so if the same value exists for more than one key, then it won't work.
In case you care, the iteration would be like this:
when HTTP_REQUEST {
foreach kv [class get dg-your-data-group] {
log local0. "key = [lindex $kv 0], value = [lindex $kv 1]"
}
}
- Mike_Dayton_108Jul 26, 2016Nimbostratus
Vernon said,
"In other words, it's a set of key/value pairs, where lookups are by key, not value."
Thanks, that is exactly what I was looking for!
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