quester
quester

Reputation: 564

Play framework - call controller in routes with Class parameter

I want to create controller method and parametrize it with Class parameter to call it in routes:

GET     /api/res1           controllers.GenericController.index(clazz:Class = Res1.class)
GET     /api/res2           controllers.GenericController.index(clazz:Class = Res2.class)

and during compilation play shouts:

[error] /home/../workspace/repo/prototype/conf/routes:26: identifier expected but 'class' found.
[error] /home/../workspace/repo/prototype/conf/routes:26: ')' expected but '}' found.

why '}' ? and how to make my idea work?

Upvotes: 2

Views: 586

Answers (1)

serejja
serejja

Reputation: 23851

Try changing to this:

/api/res1   controllers.GenericController.index(clazz: Class[_] = classOf[full.package.name.Res1])

Works just fine for me.

Upvotes: 1

Related Questions