Created
April 15, 2011 06:16
-
-
Save dhanji/921227 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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