[Flow] Routes and optional arguments/parameters
Søren Malling
soren.malling at gmail.com
Mon Oct 14 13:13:01 CEST 2013
Hi,
I'm writing my own API at the moment for a project and I'm in the part of
configuring my routes. You can find the routes nicely formatted here
https://gist.github.com/sorenmalling/6974030
or read them here
----------------
-
name : 'API'
uriPattern: 'api/{@action}(/{object})'
acceptedHttpMethods: ['POST', 'GET', 'PUT', 'DELETE']
appendExceedingArguments: TRUE
defaults:
'@package': 'Vender.Package'
'@controller': 'Rest'
'@format': 'json'
-
name : 'API'
uriPattern: 'api'
acceptedHttpMethods: ['GET']
appendExceedingArguments: TRUE
defaults:
'@package': 'Vendor.Package'
'@controller': 'Rest'
'@format': 'json'
'@action': 'help'
----------------
The aim here, is to have a fallback (/api) that will show a help message.
The fallback should only be reached if no URL in the form of
/api/team or /api/team/objectUUID os called. There is a "teamAction" inside
my RestController
When I write the /api address i get the help function and the returned JSON
but when i add the "@action" like this
http://host.tld/api/team
I get this error in return
No controller could be resolved which would match your request. Package
key: "api", controller name: "team". (GET http://host.tld/api/team)
(reference code: 201310141309521a1734)
But, if I add the optional "object" the request goes through to the
teamAction and I get my output. What part of my Routes configuration is
wrong here?
Or, does a better way to write Routes for a Rest API exist?
Cheers
Søren
More information about the Flow
mailing list