Route

io.eezo.http.Route
See theRoute companion enum
object Route

Attributes

Companion
enum
Source
Route.scala
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Route.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
Source
Mirror.scala
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror
Source
Mirror.scala

Value members

Concrete methods

def under(prefix: String)(routes: Seq[Route]): Seq[Route]

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