diff options
author | vlad <vlad@drivergrp.com> | 2016-11-29 20:54:22 -0800 |
---|---|---|
committer | vlad <vlad@drivergrp.com> | 2016-11-29 20:54:22 -0800 |
commit | d2ca9af21079656113c445bd9df69d5b90a1b618 (patch) | |
tree | a071b3a2862bfdb6f4e9df2a8f4bd975816e9485 | |
parent | 2f2eeb273b1cdc89c5283412ea85977665d9f26b (diff) | |
download | driver-core-d2ca9af21079656113c445bd9df69d5b90a1b618.tar.gz driver-core-d2ca9af21079656113c445bd9df69d5b90a1b618.tar.bz2 driver-core-d2ca9af21079656113c445bd9df69d5b90a1b618.zip |
Correct path matchers for Id and name for akka httpv0.9.20
-rw-r--r-- | src/main/scala/xyz/driver/core/json.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main/scala/xyz/driver/core/json.scala b/src/main/scala/xyz/driver/core/json.scala index cc27944..91cd58b 100644 --- a/src/main/scala/xyz/driver/core/json.scala +++ b/src/main/scala/xyz/driver/core/json.scala @@ -1,8 +1,8 @@ package xyz.driver.core import akka.http.scaladsl.model.Uri.Path -import akka.http.scaladsl.server.PathMatcher.Matched -import akka.http.scaladsl.server.{PathMatcher, _} +import akka.http.scaladsl.server.PathMatcher.{Matched, Unmatched} +import akka.http.scaladsl.server._ import akka.http.scaladsl.unmarshalling.Unmarshaller import spray.json.{DeserializationException, JsNumber, _} import xyz.driver.core.revision.Revision @@ -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]] { |