[akka-user] akka-http: access to httpresponse

2016-01-05 Thread ash.ta
hi,

i go through the akka-http java documentation 
here 
http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.1/java/http/routing-dsl/handlers.html#Handlers_in_Java_8
and there is something i need your help with.
let's say i have the following simplest handler:

Handler handler = new Handler() {

@Override
public RouteResult apply( RequestContext ctx) {
return ctx.complete("This was a " + ctx.request().method().value()  +
" request to "+ctx.request().getUri());
}
};


i need to access httpresponse object before the completion, f.e. to add 
some response headers. how do i do this? 

thanks.

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka-http: access to httpresponse

2016-01-05 Thread Konrad Malawski
Hi there,
You're the one creating the HttpResponse directly if you want to modify it, see:

import akka.http.javadsl.model.*;
return ctx.complete(
  HttpResponse.create()
.withEntity(HttpEntities.create("example"))
.addHeader(Location.create("http://akka.io";)));
Happy hakking!


-- 
Cheers,
Konrad 'ktoso’ Malawski
Akka @ Typesafe

On 5 January 2016 at 09:45:43, ash.ta (ata...@gmail.com) wrote:

hi,

i go through the akka-http java documentation here 
http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.1/java/http/routing-dsl/handlers.html#Handlers_in_Java_8
and there is something i need your help with.
let's say i have the following simplest handler:


Handler handler = new Handler() {

@Override
public RouteResult apply( RequestContext ctx) {
return ctx.complete("This was a " + ctx.request().method().value()  +
" request to "+ctx.request().getUri());
}
};

i need to access httpresponse object before the completion, f.e. to add some 
response headers. how do i do this? 

thanks.
--
>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.