diff options
author | Stewart Stewart <stewart@driver.xyz> | 2017-05-10 14:51:43 -0400 |
---|---|---|
committer | Stewart Stewart <stewart@driver.xyz> | 2017-05-10 14:52:02 -0400 |
commit | 97e75b8d777c6661461493b28d91559fabf237ba (patch) | |
tree | bf196330363f072b992487d16af32293efd78222 /src/main | |
parent | df6202fa411b1294dd481c7d6c4062c3ecdbb437 (diff) | |
download | driver-core-97e75b8d777c6661461493b28d91559fabf237ba.tar.gz driver-core-97e75b8d777c6661461493b28d91559fabf237ba.tar.bz2 driver-core-97e75b8d777c6661461493b28d91559fabf237ba.zip |
try to match uuid first in id PathMatcher
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/scala/xyz/driver/core/json.scala | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/main/scala/xyz/driver/core/json.scala b/src/main/scala/xyz/driver/core/json.scala index 67bf8e4..6f772f3 100644 --- a/src/main/scala/xyz/driver/core/json.scala +++ b/src/main/scala/xyz/driver/core/json.scala @@ -18,16 +18,11 @@ import xyz.driver.core.time.Time object json { import DefaultJsonProtocol._ - def IdInPath[T]: PathMatcher1[Id[T]] = new PathMatcher1[Id[T]] { - def apply(path: Path) = path match { - case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](segment))) - case _ => Unmatched - } - } + private def UuidInPath[T]: PathMatcher1[Id[T]] = PathMatchers.JavaUUID.map((id: UUID) => Id[T](id.toString)) - def UuidInPath[T]: PathMatcher1[Id[T]] = new PathMatcher1[Id[T]] { + def IdInPath[T]: PathMatcher1[Id[T]] = UuidInPath[T] | new PathMatcher1[Id[T]] { def apply(path: Path) = path match { - case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](UUID.fromString(segment).toString))) + case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](segment))) case _ => Unmatched } } |