Forum Discussion
BIG-IP : helper functions for composing urls with query-params
f5 BIG-IP LTM VE v11.4.0 on ESXi
In my irule, I need to construct a url from multiple segments.
Each segment is run-time loaded from a data-file.
Segment form is only partially known at design-time.
EXAMPLE 1 :
segment1 : "/folder1/folder2/id1"
segment2 : "param1=n1"
EXAMPLE 2 :
segment1 : "/folder1/folder2?param1=n1"
segment2 : "param2=n2"
EXAMPLE 3 :
segment1 : "/folder1/folder2?param1=n1¶m2=n2"
segment2 : "param3=n3"
Of course I could write a bit of conditional logic to properly compose the segments.
But I am wondering if perhaps F5 out-of-the-box provides any helper functions ?
For example , a function that would add query-params to the end of a url, and automatically include ? ( if necessary ) or & ( if necessary )
1 Reply
- Arnaud_Lemaire
Employee
hi, Question mark is automatically added when you manipulate HTTP::query
you can in 11.5 create proc to achieve you results:
proc add_query { query } { if { [HTTP::query] equals "" } { return [HTTP::query]$query } else { return [HTTP::query]&$query } } when HTTP_REQUEST { log local0. "-----------------------------" log local0. "base uri: [HTTP::uri]" log local0. "base query: [HTTP::query]" HTTP::query [call add_query secondparam=tata] log local0. "uri after proc: [HTTP::uri]" }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
