Reputation: 1658
My "routes" file looks something like:
# Routes
GET / controllers.Application.action(p1 ?= 1, p2 ?= 2, p3 ?= "", p4 ?= "")
I want to have something like:
case class FilterGroup(p1: Int, p2: Int, p3: String, p4: String) // defined in controllers
# Routes
GET / controllers.Application.action(fg ?= FilterGroup(1, 2, "", ""))
The advantages is that it will give more extensibility in .scala.html when you need to add or remove some parameters.
Is that possible to implement?
Upvotes: 3
Views: 768
Reputation: 365
Take a look at QueryStringBindable and PathBindable traits. Try to implement implicit binders for your case classes (here is example), and then you need to set in project settings in your build.sbt route import with packages in which kept your case classes and binders:
routesImport ++= Seq("foo", "bar")
Upvotes: 2