QueryString / Path Binder for Play 2.x
Scala
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
project
src
.gitignore
.travis.yml
README.md
build.sbt
scalariform.sbt

README.md

play-joda-routes-binder

Build Status

QueryString / Path Binder for Play 2.x

Usage

Add dependency and routesImport to your Build.scala

libraryDependencies ++= Seq(
  // for Play 2.6
  "com.github.tototoshi" %% "play-joda-routes-binder" % "1.2.0"
  // for Play 2.5
  // "com.github.tototoshi" %% "play-joda-routes-binder" % "1.1.0"
)
    
routesImport += "com.github.tototoshi.play2.routes.JodaRoutes._"

Now you can bind query string and path parameters to LocalDate and DateTime.

GET     /list                 controllers.Application.index(date: org.joda.time.LocalDate)
GET     /entry/$date<[0-9]+>  controllers.Application.entry(date: org.joda.time.LocalDate)

Default format of LocalDate and DateTime is 'yyyyMMdd'. You can override this behavior if you don't like it. Add the customized binder to your Build.scala

package example

object MyRoutes {
  val myJodaRoutes = new com.github.tototoshi.play2.routes.JodaRoutes {
    override val format: String = "yyMMdd"
  }
}
routesImport += "example.MyRoutes.myJodaRoutes._"

License

Apache 2.0