Attributes
- Companion
- enum
- Source
- Route.scala
- Graph
-
- Supertypes
- Self type
-
Route.type
Members list
Type members
Inherited and Abstract types
The names of the product elements.
The name of the type.
Value members
Concrete methods
Mounts a set of routes under a prefix: the paths they answer on, and the URLs they emit.
Mounts a set of routes under a prefix: the paths they answer on, and the URLs they emit.
Moving the pattern alone is half a mount. A page whose links were built before the prefix existed keeps pointing at the unmounted path, so an anchor 404s, a form posts nowhere and a redirect lands outside the mount. Which URLs move is decided where they are written: a Url.Mounted is the application's own and travels, a String and a Url.Absolute are finished addresses and are left exactly as written.
A plain function over Seq[Route] rather than a parameter on Resource, because Route is public and that makes relocation free for handwritten routes too. Route transformation is the general shape here: authorization and the middleware modules/auth will want are the same Seq[Route] => Seq[Route], so neither has to invent a mechanism.
The prefix is normalised rather than validated, since /admin, admin and /admin/ are one intention written three ways, and rebuilding through PathPattern.parse is what keeps the moved pattern under the same parse-time validation as the original. Url.normalise does that normalising rather than a trim written here, because the prefix reaches the emitted URLs through Url anyway: two spellings of one rule are two rules waiting to disagree, and a path a route answers on that disagrees with the path its links point at is the bug this whole function exists to prevent. / is the identity prefix, and an empty string spells it too.
Attributes
- Source
- Route.scala