Skip to content

Instantly share code, notes, and snippets.

@dhanji
Created April 15, 2011 06:16
Show Gist options
  • Save dhanji/921227 to your computer and use it in GitHub Desktop.
Save dhanji/921227 to your computer and use it in GitHub Desktop.
@At("/person") @Async
public class PersonService {
@Before
void pre(Request request) {
System.out.println("headers were: " + request.headers());
}
/**
* Callback for request body. Can return a continuation, which will
* keep calling this method until the request is completely read, then
* call @After. OR if this method returns a reply, we stop reading the
* request and send a response directly.
*/
@Post
Reply<?> savePerson(Request request) {
if (request.done())
return Reply.with("OK");
// Read entity asynchronously, then call us back when read.
return request.read(Person.class).as(Json.class).andContinue();
}
/**
* Callback for when response is completely written.
*/
@After
void completed() {
// Release additional resources here.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment