aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlad <vlad@drivergrp.com>2016-12-07 01:00:05 -0800
committervlad <vlad@drivergrp.com>2016-12-07 01:00:05 -0800
commit6caefbf595aef916129fba2f012bfe8b2e6b5e58 (patch)
tree2989a0129edf2d59d3ea809680977b103727274b
parentd52f22870144fd838a469920061fb1d8dc22902a (diff)
downloaddriver-core-0.9.25.tar.gz
driver-core-0.9.25.tar.bz2
driver-core-0.9.25.zip
Lost important PathMatcher bugfixv0.9.25
-rw-r--r--src/main/scala/xyz/driver/core/json.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/scala/xyz/driver/core/json.scala b/src/main/scala/xyz/driver/core/json.scala
index cc27944..66cae52 100644
--- a/src/main/scala/xyz/driver/core/json.scala
+++ b/src/main/scala/xyz/driver/core/json.scala
@@ -1,7 +1,7 @@
package xyz.driver.core
import akka.http.scaladsl.model.Uri.Path
-import akka.http.scaladsl.server.PathMatcher.Matched
+import akka.http.scaladsl.server.PathMatcher.{Matched, Unmatched}
import akka.http.scaladsl.server.{PathMatcher, _}
import akka.http.scaladsl.unmarshalling.Unmarshaller
import spray.json.{DeserializationException, JsNumber, _}
@@ -13,7 +13,10 @@ import scala.reflect.runtime.universe._
object json {
def IdInPath[T]: PathMatcher1[Id[T]] = new PathMatcher1[Id[T]] {
- def apply(path: Path) = Matched(Path.Empty, Tuple1(Id[T](path.toString)))
+ def apply(path: Path) = path match {
+ case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](segment)))
+ case _ => Unmatched
+ }
}
implicit def idFormat[T] = new RootJsonFormat[Id[T]] {
@@ -26,7 +29,10 @@ object json {
}
def NameInPath[T]: PathMatcher1[Name[T]] = new PathMatcher1[Name[T]] {
- def apply(path: Path) = Matched(Path.Empty, Tuple1(Name[T](path.toString)))
+ def apply(path: Path) = path match {
+ case Path.Segment(segment, tail) => Matched(tail, Tuple1(Name[T](segment)))
+ case _ => Unmatched
+ }
}
implicit def nameFormat[T] = new RootJsonFormat[Name[T]] {