So in Play 2.0 I had this:
GET /tasks/add controllers.Tasks.addTask(parentId: Option[Long] = None)
GET /tasks/:parentId/add controlle
Play 2.0 supported Option
in path parameters, Play 2.1 no longer supports this, they removed the PathBindable for Option.
One possible solution would be:
package extensions
import play.api.mvc._
object Binders {
implicit def OptionBindable[T : PathBindable] = new PathBindable[Option[T]] {
def bind(key: String, value: String): Either[String, Option[T]] =
implicitly[PathBindable[T]].
bind(key, value).
fold(
left => Left(left),
right => Right(Some(right))
)
def unbind(key: String, value: Option[T]): String = value map (_.toString) getOrElse ""
}
}
And add this to Build.scala
using routesImport += "extensions.Binders._"
. Run play clean ~run
and it should work. Reloading the Binders on the fly only sometimes works.