cancel
Showing results for 
Search instead for 
Did you mean: 

HowTo: if-then-else conditions in TrafficScript

TrafficScript provides ‘if’ and ‘if/else’ statements for conditional execution.  The condition is an expression, which is evaluated.

 

The return value of the expression determines whether the condition is ‘true’ or ‘false’:

 

  • A non-zero number or non-empty string is ‘true’;
  • A zero number or empty string is ‘false’.

 

For example:

 

if( $url == "/" ) {  
   log.info( "Access to home page" );  
}

 

... or

 

if( $isAuthenticated ) {  
   pool.use( "local pool" );  
} else {   
   log.info( "Unauthenticated user accessed the service" );   
   connection.close();  
} 

 

Read more: Collected Tech Tips: TrafficScript examples

Version history
Revision #:
1 of 1
Last update:
‎02-24-2013 05:33:AM
Updated by:
 
Labels (1)