Flow
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.
Here we have a flow with if-elseif-else
conditional statements and some echo
actions evaluating the $request
variable:
Control Structures
break
break
break
stops the flow processing for the current request. It may be used in sub flows or the init flow, too.
Response processing (such as validation and sending out the response) will continue, though.
A break
statement should usually be executed conditionally, because otherwise none of the following statements will ever be executed.
See also:
if
-elseif
-else
if
-elseif
-else
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
if
attributeThe if
attribute allows for conditional execution of a single action:
return
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
.
Last updated