I'm using akka-http 1.0.-RC4.

How can I extract Future[T] value in unmarshaller without blocking ? 

Details are 
here 
http://stackoverflow.com/questions/31223016/why-akka-http-unmarshaler-returns-futuret-instead-of-t
 
but in short here is what I want to do.

I extended ScalaXmlSupport you created to support unmarshalling http 
requests using Unmarshaller[NodeSeq, T] unmarshallers by adding this

implicit def xmlUnmarshallerConverter[T](marshaller: Unmarshaller[NodeSeq, T
])(implicit mat: Materializer): FromEntityUnmarshaller[T] =
xmlUnmarshaller(marshaller, mat)

implicit def xmlUnmarshaller[T](implicit marshaller: Unmarshaller[NodeSeq, T], 
mat: Materializer): FromEntityUnmarshaller[T] = {
implicit val exec = mat.executionContext
defaultNodeSeqUnmarshaller.map(v => {
val future = marshaller(v)(mat.executionContext)
val result = Await.result(future, Duration(10, TimeUnit.SECONDS))
result
})
}

The only problem is that prototype of Unmarshaller.apply is this

def apply[A, B](f: ExecutionContext ⇒ A ⇒ Future[B]): Unmarshaller[A, B]


It requires me to returns Future which I do by creating unmarshallers of 
model classes like

implicit val articleBodyUnmarshaller = Unmarshaller[NodeSeq, ArticleBody] { xml 
=>
  Future(ArticleBody(xml.toString()))
}


But I can't use it in xmlUnmarshaller : FromEntityUnmarshaller[T] because 
it requires me to return concrete object which forces me to do ugly blocking

How should I write it properly ?

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to