Get String from RequestEntity using java

Hello all ,
Which is the recommended method to get the RequestEntity as String .
I tried two different paths:
(1)
Source<ByteString, Object> source = RequestEntity.getDataBytes();
I’m not sure what I’m supposed to do with the source , it has a lot of methods, and it’s unclear how to use those and if any of them can actually help me.
(2)
Unmarshaller<HttpEntity, String> unmarshaller = Unmarshaller.entityToString();
CompletionStage result = unmarshaller.unmarshall(entity, ExecutionContext, Materializer);

Calling unmarshaller.unmarshall requires not only an instance of RequestEntity but also an ExecutionContext and a Materializer which I do not have at the part of the unmarshalling, also it returns a CompletionStage<String> which is completely redundant as I want it to be done synced.

Can help me with some hints please ?
Many thanks in advance ,
Stefan

P.S is there any way to enable the debug messages of akka-http-server in order to see the flow of events and why at big requests the server hangs ?

Hi

If you are building a HTTP server with Akka HTTP and are new to the Akka landscape I’d recommend that you use the higher level server DSL for Java. And among the directives in that you have the entity directive which extracts and unmarshalls the request body for you.

For the lower level APIs dealing with HttpRequest and HttpResponse directly you will have learn a bit of the underlying technologies. I recommend that you read up on those in the docs in that case, figuring them out by trial and error can be quite painful experience. Especially important is to understand the Akka Streams APIs and the implications of Akka HTTP being built upon those