Hi there,
the Unmarshaller type you wrote is correct, however the infrastructure is async
in any case – inside withMaterialized you return a Future.
implicit val um: Unmarshaller[Future[String], String] = ???
val eventualString: Future[String] = Unmarshal(Future("")).to[String](um,
I am not sure I understood, would this be blocking?
implicit def liftUnmarshaller[A,B](implicit unmarshaller:Unmarshaller[A,B]):
Unmarshaller[Future[A],B] = Unmarshaller.withMaterializer(
ec => m => a => a.flatMap{ x =>
unmarshaller.apply(x)(ec,m)
}(ec)
)
Il giorno venerdì 22 aprile
> On 22 Apr 2016, at 12:11, Edmondo Porcu
> wrote:
>
> Shouldn't be possible to lift the unmarshaller with an implicit conversion?
How? Do you want to block?
Heiko
--
>> Read the docs: http://akka.io/docs/
>> Check the FAQ:
Shouldn't be possible to lift the unmarshaller with an implicit conversion?
--
>> Read the docs: http://akka.io/docs/
>> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> Search the archives:
Edmondo,
You can’t expect unmarshalling to magically unfold the Future you get back.
Hence you have to map. Or, to be more precise, you have to flatMap, because
unmarshalling returns another Future.
```
responseFuture.flatMap(Unmarshal(_).to[MyClass]) // Notice that you’re still in
Future