hi hakkers,
i asked this as a part of a discussion in other thread but got no answer, so i'm trying my luck here.
i use akka-http with java api. i need to return a json entity in httpresponse with response headers. i was advised to do something like this:
return ctx.complete(
HttpResponse.create()
.withEntity(HttpEntities.create("example"))
.addHeader(Location.create("http://akka.io")));
my problem is that i don't know how to send a json entity. the docs show a way to use marshallers which doesn't involve httpresponse object, which unfortunately doesn't answer my needs:
ctx.completeAs(Jackson.json(), object)
i tried a workaround
response.withEntity( json_string ).addHeader( new RawHeader( "Content-Type", "application/json" ) )
but this doesn't work - the response arrives with content-type text/plain and i see following warn in logs: Explicitly set HTTP header 'Content-Type: application/json' is ignored, illegal RawHeader.
any ideas?
thanks!