-
Notifications
You must be signed in to change notification settings - Fork 0
Simple Routing
Frapi has a very simple Routing mechanism.
When creating an action through the admin interface and setting the “custom route” field, you may set the route to contain a dynamic variable. Please note that there is not regular expression support in the routes just yet. You may add them if you wish and propose a patch.
If you look closely at the following screenshot of the action creator in the administration interface:
You’ll notice that the defined route is /custom/route/:param
The URL facing the users of your API will then look like something as such as /custom/route/frapi which associates frapi to the variable param
In order to access the value in your controller say in your modules’ executeGet() you would then do: $param = $this→getParam(‘param’);
As previously described in the aforementioned block, if you create a custom route called /custom/route/:param the param key will be associated to the value passed in the URL.
Consider the following URL /path/to/:resource/:name which once accessed by your users will be more like something that looks like: /path/to/product/david.
A tabular key-value association for this would like:
| Key | Value |
| resource | product |
| name | david |
Remember that in order to access those keys from the execute*() controllers, you’ll need to use their key names in the $this→getParam(‘keyname’) method call.
