final case class Rule[Page](parse: (Path) ⇒ Option[Parsed[Page]], path: (Page) ⇒ Option[Path], action: (Path, Page) ⇒ Option[Action[Page]]) extends Product with Serializable
A single routing rule. Intended to be composed with other Rules. When all rules are composed, this is turned into a Rules instance.
- Page
The type of legal pages.
- parse
Attempt to parse a given path.
- path
Attempt to determine the path for some page.
- action
Attempt to determine the action when a route resolves to some page.
- Alphabetic
- By Inheritance
- Rule
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val action: (Path, Page) ⇒ Option[Action[Page]]
-
def
addCondition(cond: (Page) ⇒ CallbackTo[Boolean])(condUnmet: (Page) ⇒ Option[Action[Page]]): Rule[Page]
Prevent this rule from functioning unless some condition holds, passes in the page requested as part of the context.
Prevent this rule from functioning unless some condition holds, passes in the page requested as part of the context. When the condition doesn't hold, an alternative action may be performed.
- cond
Function that takes the requested page and returns true if the page should be rendered.
- condUnmet
Response when rule matches but condition doesn't hold. If response is
Noneit will be as if this rule doesn't exist and will likely end in the route-not-found fallback behaviour.
-
def
addCondition(cond: CallbackTo[Boolean])(condUnmet: (Page) ⇒ Option[Action[Page]]): Rule[Page]
Prevent this rule from functioning unless some condition holds.
Prevent this rule from functioning unless some condition holds. When the condition doesn't hold, an alternative action may be performed.
- condUnmet
Response when rule matches but condition doesn't hold. If response is
Noneit will be as if this rule doesn't exist and will likely end in the route-not-found fallback behaviour.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
autoCorrect(redirectMethod: Method): Rule[Page]
When a route matches a page, compare its Path to what the route would generate for the same page and if they differ, redirect to the generated one.
When a route matches a page, compare its Path to what the route would generate for the same page and if they differ, redirect to the generated one.
Example: If a route matches
/issue/dev-23and returns aPage("DEV", 23)for which the generate path would be/issue/DEV-23, this would automatically redirect/issue/dev-23to/issue/DEV-23, and process/issue/DEV-23normally using its associated action. -
def
autoCorrect: Rule[Page]
See autoCorrect().
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
fallback(fp: (Page) ⇒ Path, fa: (Path, Page) ⇒ Action[Page]): Rules[Page]
Specify behaviour when a
Pagedoesn't have an associatedPathorAction. -
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
modPath(add: (Path) ⇒ Path, remove: (Path) ⇒ Option[Path]): Rule[Page]
Modify the path(es) generated and parsed by this rule.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
noFallback: Rules[Page]
When a
Pagedoesn't have an associatedPathorAction, throw a runtime error.When a
Pagedoesn't have an associatedPathorAction, throw a runtime error.This is the trade-off for keeping the parsing and generation of known
Pages in sync - compiler proof ofPageexhaustiveness is sacrificed.It is recommended that you call RouterConfig.verify as a sanity-check.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val parse: (Path) ⇒ Option[Parsed[Page]]
- val path: (Page) ⇒ Option[Path]
- def pmap[W](f: (Page) ⇒ W)(pf: PartialFunction[W, Page]): Rule[W]
- def pmapCT[W](f: (Page) ⇒ W)(implicit ct: ClassTag[Page]): Rule[W]
- def pmapF[W](f: (Page) ⇒ W)(g: (W) ⇒ Option[Page]): Rule[W]
-
def
prefixPath(prefix: String): Rule[Page]
Add a prefix to the path(es) generated and parsed by this rule.
-
def
prefixPath_/(prefix: String): Rule[Page]
Add a prefix to the path(es) generated and parsed by this rule.
Add a prefix to the path(es) generated and parsed by this rule.
Unlike prefixPath() when the suffix is non-empty, a slash is added between prefix and suffix.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def widen[W >: Page](pf: PartialFunction[W, Page]): Rule[W]
- def widenCT[W >: Page](implicit ct: ClassTag[Page]): Rule[W]
- def widenF[W >: Page](f: (W) ⇒ Option[Page]): Rule[W]
- def xmap[A](f: (Page) ⇒ A)(g: (A) ⇒ Page): Rule[A]
-
def
|(that: Rule[Page]): Rule[Page]
Compose rules.