Browse Source

Add path extractor for extracting variables from urls

master
Zak Patterson 5 years ago
parent
commit
e3f195ca49
  1. 15
      outwatch-router/src/main/scala/outwatch/router/Path.scala
  2. 2
      project/Version.scala

15
outwatch-router/src/main/scala/outwatch/router/Path.scala

@ -84,6 +84,21 @@ final case class /(parent: Path, child: String) extends Path {
}
}
/**
* Path separator extractor:
* {{{
* Path("/1/2/3/test.json") match {
* case "1" /: "2" /: _ => ...
* }}}
*/
object /: {
def unapply(path: Path): Option[(String, Path)] =
path.toList match {
case head :: tail => Some(head -> Path(tail))
case Nil => None
}
}
/**
* Root extractor:
* {{{

2
project/Version.scala

@ -1,4 +1,4 @@
object Version{
val version = "0.0.1"
val version = "0.0.2"
val scalaVersion = "2.12.8"
}
Loading…
Cancel
Save