I'd like to provide optional plurality to my routes in a Play application. For example:
/path/1
/paths/1
The route URL I tried was something like this:
/path<[s?]>/:id
If I put just a $ in front of it, it asks for an identifier; if I given it an identifier, it tells me I need to use it in the call definition. Is what I'm trying to do possible without having to do a Cartesian product of every possibly with/out combination of plurality?
Scala is used in Data processing, distributed computing, and web development. It powers the data engineering infrastructure of many companies.
The Advantages of ScalaScala has an exact syntax, eliminating boilerplate code. Programs written in Scala require less code than similar programs written in Java. It is both an object-oriented language and a functional language. This combination makes Scala the right choice for web development.
If we look “under the hood,” Scala is an object-oriented programming language that also incorporates a lot of the functional programming attributes a language like Python is loved for. However, Scala is a distinctly different language than Python.
Scala's is geared more towards compile-time safety with generic code working properly at runtime, while C++ is geared more towards code generation via templates. The C++ type system is way safer than that of Scala. The latter type system has no real distinction between compile-time and runtime.
If my understanding of the RoutesCompiler is correct (especially the check
function), any dynamic part in the URL must be used in the call definition.
So it looks like the only option is adding a new parameter like this:
GET /$p<paths?>/:id controllers.PathController.get(p, id)
GET /otherpath$p<s?>/:id controllers.OtherController.get(p, id)
Then just ignore the p
parameter. You will need to provide it when using reverse routes though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With