Forum Discussion
iRule Script Keywords
Hello All,
I am searching for the purpose and difference between below iRule Keywords :
1- log local0.info purpose and when to use it.
2- Difference between Eq , Starts_with and contains : I feel they are almost doing the same work but When to use which Keyword.
3- Difference between [HTTP::path] and [HTTP:uri].
4- "return" keywork in irule.
5.- switch -glob : What is the relevance if we use only "switch" in irule and what are the consequences if we add -glob to switch.
6-
eagertolearn I think it would be in your best interest to do some beginner programming to assist you with some of the logic of iRules. Now the follow are you questions and my answers.
Q1- log local0.info purpose and when to use it.
A1- local0 logs to the F5 ltm logs for a specific section that matches in your iRule and I believe the .info sets the log message level to info so if you have something that searches for logs at that level this would match that filter.Q2- Difference between Eq , Starts_with and contains : I feel they are almost doing the same work but When to use which Keyword.
A2- eq means match something exactly, starts_with means the value you are matching starts_with that, and finally contains means anywhere in the value you are matching it will have your matching variable. As an example if you did [HTTP::host] eq "example.com" it would only match example.com and nothing else. If you had starts_with "hello." the host was hello.example.com then that would match. Finally, if you had contains "hello" and the host was earth.hello.example.com then it would match because you are just searching for the existence of "hello" in the string.Q3- Difference between [HTTP::path] and [HTTP:uri].
A3- So if you had URL http://www.example.com:8080/main/index.jsp?user=test&login=check the URI would be /main/index.jsp?user=test&login=check and the path, which ignores the query string would be /main/index.jspQ4- "return" keywork in irule.
A4- I believe this article explains it better than I can. https://clouddocs.f5.com/api/irules/return.htmlQ5- switch -glob : What is the relevance if we use only "switch" in irule and what are the consequences if we add -glob to switch.
A5- So typically you use a switch to reduce the overall length of an iRule if you are just doing if elseif over and over again, and this should also reduce the overall memory usage rather than having a long iRule with a bunch of if elseif statements. The following article goes into iRules a bit if you would like to read it over. Getting Started with iRules: Control Structures & Operators | DevCentral
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