The flow describes how the incoming request from the client is transformed into the outgoing response. The flow comprises actions, control structures and variables.
Each endpoint of your API can have its individual flow specified by x-flat-flow, see Routing.
The if statement and the optional elseif and else statements allow for conditional execution of flow blocks.
Conditional expressions are defined in the test="…" attributes of the if and elseif statements. If such an expression evaluates to true, the flow block inside that if (or elseif) will be executed. All directly following elseif and else blocks will then be skipped.
If the result of that expression is false, the block will be skipped and the condition of the following elseif statement will be checked, if applicable.
The block associated with the first matching conditional expression will be executed – or if all expressions were evaluated to false, the else block will be executed.
if attribute
The if attribute allows for conditional execution of a single action:
return
return quits the current sub flow and returns to its parent flow. If return is used in the init flow the regular API path flow will still be executed. A return statement on the top-most flow behaves like break.