Hi,

TLDR: I'd like to use the materialized value of a stream to decide the 
HttpResponse code.

Presently, I use a ToEntityMarshaller which marshals to:
HttpEntity.Chunked(_, Source[Chunk, Future[Boolean]])

The Materialized Future[Boolean] indicates whether the stream was 
completely empty which is knowable as soon as an instance of the Source is 
run.

Since streams can be transformed multiple ways, and run multiple times, I'd 
prefer to have the state which indicates whether the stream is empty come 
from a materialized stream.

So, what I'd like to know, is if it's possible to use the stream 
materialized value to inform the response headers / code in a 
ToResponseMarshallable. As far as I can tell, from reading the source code 
of akka-http, it doesn't seem possible (a layer later in the process 
materializes the Source[Chunk, Any] AFTER an HttpResponse (containing the 
code, headers, and entity) is fully generated.

If this is possible, can someone point me to an example?

By the way, the stream integration for Akka HTTP is really, really amazing! 
Great work on it, Akka devs! I'm planning to blog about this and do a 
little walk-through tutorial on how to content-negotiated streaming of 
either JSON or protocol buffers.

Thanks!

Tim

-- 
>>>>>>>>>>      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