Skip to content

Commit

Permalink
docs/cookbooks: core - proper details about no-return in route block
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Jan 24, 2025
1 parent 9914278 commit 9b6281a
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 31 deletions.
8 changes: 5 additions & 3 deletions docs/cookbooks/5.2.x/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -3221,9 +3221,11 @@ In bool expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit \[val\].
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

Expand Down
8 changes: 5 additions & 3 deletions docs/cookbooks/5.3.x/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -3346,9 +3346,11 @@ In bool expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit \[val\].
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

Expand Down
8 changes: 5 additions & 3 deletions docs/cookbooks/5.4.x/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -3417,9 +3417,11 @@ In bool expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit \[val\].
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

Expand Down
12 changes: 9 additions & 3 deletions docs/cookbooks/5.5.x/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -3620,9 +3620,11 @@ In bool expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit \[val\].
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

Expand Down Expand Up @@ -4111,6 +4113,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see
The sub-route blocks allow to make the configuration file modular,
simplifying the logic and helping to avoid duplication of actions.

If no `return` is at the end of the routing block, the return code is the value
of the last executed action, therefore it is highly recommended to return an
explicit value (e.g., `return(1)`) to avoid unexpected config execution.

### branch_route

Request's branch routing block. It contains a set of actions to be taken
Expand Down
12 changes: 9 additions & 3 deletions docs/cookbooks/5.6.x/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -3748,9 +3748,11 @@ In bool expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`.
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

Expand Down Expand Up @@ -4238,6 +4240,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see
The sub-route blocks allow to make the configuration file modular,
simplifying the logic and helping to avoid duplication of actions.

If no `return` is at the end of the routing block, the return code is the value
of the last executed action, therefore it is highly recommended to return an
explicit value (e.g., `return(1)`) to avoid unexpected config execution.

### branch_route

Request's branch routing block. It contains a set of actions to be taken
Expand Down
14 changes: 10 additions & 4 deletions docs/cookbooks/5.7.x/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4400,9 +4400,11 @@ In logical evaluation expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`.
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

Expand Down Expand Up @@ -4868,7 +4870,7 @@ Example of usage:
}
```

### route
### route block

This block is used to define 'sub-routes' - group of actions that can be
executed from another routing block. Originally targeted as being
Expand Down Expand Up @@ -4920,6 +4922,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see
The sub-route blocks allow to make the configuration file modular,
simplifying the logic and helping to avoid duplication of actions.

If no `return` is at the end of the routing block, the return code is the value
of the last executed action, therefore it is highly recommended to return an
explicit value (e.g., `return(1)`) to avoid unexpected config execution.

### branch_route

Request's branch routing block. It contains a set of actions to be taken
Expand Down
12 changes: 9 additions & 3 deletions docs/cookbooks/5.8.x/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4511,9 +4511,11 @@ In logical evaluation expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`.
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

Expand Down Expand Up @@ -5031,6 +5033,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see
The sub-route blocks allow to make the configuration file modular,
simplifying the logic and helping to avoid duplication of actions.

If no `return` is at the end of the routing block, the return code is the value
of the last executed action, therefore it is highly recommended to return an
explicit value (e.g., `return(1)`) to avoid unexpected config execution.

### branch_route

Request's branch routing block. It contains a set of actions to be taken
Expand Down
24 changes: 15 additions & 9 deletions docs/cookbooks/devel/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4648,28 +4648,30 @@ In logical evaluation expressions:
- Negative is FALSE
- Positive is TRUE

If no value is specified, or a route reaches its end without executing a
return statement, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`.
If no value is specified, it returns 1. If return is used in the top level route
is equivalent with exit `[val]`. If no `return` is at the end of the routing block,
the return code is the value of the last executed action, therefore it is highly
recommended to return an explicit value (e.g., `return(1)`) to avoid unexpected
config execution.

Example usage:

``` c
request_route {
if (route(RET)) {
xlog("L_NOTICE","method $rm is INVITE\n");
xlog("L_NOTICE","method $rm is INVITE\n");
} else {
xlog("L_NOTICE","method $rm is REGISTER\n");
xlog("L_NOTICE","method $rm is REGISTER\n");
};
}

route[RET] {
if (is_method("INVITE")) {
return(1);
return(1);
} else if (is_method("REGISTER")) {
return(-1);
return(-1);
} else {
return(0);
return(0);
};
}
```
Expand Down Expand Up @@ -5125,7 +5127,7 @@ Example of usage:
}
```

### route
### route block

This block is used to define 'sub-routes' - group of actions that can be
executed from another routing block. Originally targeted as being
Expand Down Expand Up @@ -5177,6 +5179,10 @@ number of recursive levels, avoiding ending up in infinite loops -- see
The sub-route blocks allow to make the configuration file modular,
simplifying the logic and helping to avoid duplication of actions.

If no `return` is at the end of the routing block, the return code is the value
of the last executed action, therefore it is highly recommended to return an
explicit value (e.g., `return(1)`) to avoid unexpected config execution.

### branch_route

Request's branch routing block. It contains a set of actions to be taken
Expand Down

0 comments on commit 9b6281a

Please sign in to comment.