Reputation: 5423
I have a strange problem
this is what I have in routes
files
GET /path/list controllers.path.getPaths()
GET /path/:id controllers.path.get(id:Int)
when I try to go <domain>/path/list
the following error shows up:
For request 'GET /path/list' [Cannot parse parameter id as Int: For input string: "list"]
I also tried to change the order in routes
file
GET /path/:id controllers.path.get(id:Int)
GET /path/list controllers.path.getPaths()
I still get the same error. so my question is
Upvotes: 2
Views: 1261
Reputation: 4116
From the code you've provided this should work. The routes are not ambiguous because (from Play documentation):
Many routes can match the same request. If there is a conflict, the first route (in declaration order) is used.
if your routes
ordering looks like this:
GET /path/list controllers.path.getPaths()
GET /path/:id controllers.path.get(id:Int)
/path/list
will match before attempting to extract/transform the id parameter id:Int
from the path and throwing.
If you want Play to transform the incoming parameter into a specific Scala type, you can add an explicit type
The only way this would not work is if you attempted to visit a route that did not match list
or was not an Int
:
For request 'GET /path/lists' [Cannot parse parameter id as Int: For input string: "lists"]
Upvotes: 4