Say this is my router config
<apikit:config name="apiConfig" raml="api.raml" doc:name="Router" >
<apikit:flow-mapping resource="/resourceOne" action="get" flow-ref="flow-1"/>
<apikit:flow-mapping resource="/resourceTwo" action="post" flow-ref="flow-1"/>
</apikit:config>
As you can see the calls to these two resources are being redirected to the same flow, but based on the method action.
How do I read this action value (Get or Post) in the called flow flow-1
?
I believe you should be having separate flows, but if you need to it this way, you can use #[attributes.method]
to get the method of the HTTP Request. The APIKIT router will forward the same event that the HTTP Listener will receive, so it will contain HTTPRequestAttributes
. For more info you can refer this section HTTP Request Example