Thanks. It seams that it worked: 

  type FutureResponse = Future[HttpResponse]
  type FutureResponseMarshaller[T] = Marshaller[T, FutureResponse]

  def httpResponse(iterator: Iterator[Data])(implicit ec: ExecutionContext) 
= {
    Source.fromGraph(sourceGrap(iterator)).runWith(entitySink).map(entity => 
HttpResponse(entity = entity))
  }

  val toResponseIteratorJsonMarshaller: FutureResponseMarshaller[Iterator[
Data]] =
    Marshaller.withFixedContentType(`application/json`) {
      result => httpResponse(result)
    }

  implicit val toResponseIteratorMarshaller: FutureResponseMarshaller[
Iterator[Data]] =
    Marshaller.oneOf(
      toResponseIteratorJsonMarshaller,
      toResponseIteratorOdsMarshaller,
      toResponseIteratorExcelMarshaller
    )

   complete {
     val result = ???
     Marshal(result).to[FutureResponse].flatMap(identity)
   }




On Tuesday, September 26, 2017 at 4:13:15 PM UTC+3, 
[email protected] wrote:
>
> Oops, one should read the whole question before answering... Just saw that 
> you already tried that. Unfortunately, it seems that this is indeed a 
> shortcoming of the current model.
>
> I guess with a bit of fiddling you could try making all of those 
> marshallers marshal to `Future[HttpResponse]` instead of `HttpResponse` and 
> then use something like
>
>
>
> val toResponseIteratorJsonMarshaller: Marshaller[Iterator[Data], 
> Future[HttpResponse]] =
>     Marshaller.withFixedContentType(`application/json`) {
>       result => httpResponse(result)
>     }
>
>   implicit val toResponseIteratorMarshaller: Marshaller[Iterator[Data], 
> Future[HttpResponse]] =
>     Marshaller.oneOf(
>       toResponseIteratorJsonMarshaller,
>       toResponseIteratorOdsMarshaller,
>       toResponseIteratorExcelMarshaller
>     )
>
> and then in your route:
>
> val responseFuture =
> Marshal(data).toResponseFor(request)(toResponseIteratorMarshaller): // 
> Future[Future[HttpResponse]]
>
> .flatMap(identity)
> complete(responseFuture)
>
> Would be interesting to know if that works.
>
> Johannes
>

-- 
>>>>>>>>>>      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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to