With Play and Scala, type-safe web development is a breeze.
The following example shows how Play parses url paths and derives values of an Scala enumeration. There are two valid url paths: /signup/company and /signup/sales. Other url paths, such as /signup/unknown are properly handled as invalid.
Play handles routes with variable parts like /signup/:account. In our case, it tries to parse the variable part :account to an enumerated type Account.Value, using the function bindableAccount.
The value is passed to the Controller, which passes it directly to the View in this example.
Oh, btw – links to these urls are type-safe, too: href="@routes.SignUp.form(Account.Company)"
2 Responses to “Play with Scala: Url Path Binding”