diff options
Diffstat (limited to 'core-rest/src/main/scala/xyz/driver/core/rest/directives/Unmarshallers.scala')
-rw-r--r-- | core-rest/src/main/scala/xyz/driver/core/rest/directives/Unmarshallers.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core-rest/src/main/scala/xyz/driver/core/rest/directives/Unmarshallers.scala b/core-rest/src/main/scala/xyz/driver/core/rest/directives/Unmarshallers.scala index 6c45d15..93a9a52 100644 --- a/core-rest/src/main/scala/xyz/driver/core/rest/directives/Unmarshallers.scala +++ b/core-rest/src/main/scala/xyz/driver/core/rest/directives/Unmarshallers.scala @@ -16,6 +16,16 @@ trait Unmarshallers { Id[A](UUID.fromString(str).toString) } + implicit def uuidIdUnmarshaller[A]: Unmarshaller[String, UuidId[A]] = + Unmarshaller.strict[String, UuidId[A]] { str => + UuidId[A](UUID.fromString(str)) + } + + implicit def numericIdUnmarshaller[A]: Unmarshaller[Long, NumericId[A]] = + Unmarshaller.strict[Long, NumericId[A]] { x => + NumericId[A](x) + } + implicit def paramUnmarshaller[T](implicit reader: JsonReader[T]): Unmarshaller[String, T] = Unmarshaller.firstOf( Unmarshaller.strict((JsString(_: String)) andThen reader.read), |