Hi,

Yes, what you are doing is a perfectly ok way to handle this.
Optionally you could use a shared resource for this, but I say that's just a matter of preference.

We use something inspired by https://code.google.com/p/wicket-rest/
This gives you some abstraction over the json (or xml/...) handling.
Furthermore you can override sensible methods like "doGet" or "doPost" which clearly communicate intent.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 14-8-2013 20:32, schreef robianmcd:
I found that this works but I'm not sure if there is a better way of doing
this:

@MountPath(value = "/api/my/rest/url")
public class MyPostHandler extends SecureWebPage {

public MyPostHandler () {
     final WebRequest webRequest = (WebRequest) getRequest();
     final HttpServletRequest rawRequest = (HttpServletRequest)
webRequest.getContainerRequest();

     if (rawRequest.getMethod().equalsIgnoreCase("POST")) {

         BufferedReader br;
               try {
                   br = rawRequest.getReader();
                   String jsonString = br.readLine();
                   //Do something with the JSON here
               }
               catch (IOException e) {

               }

     }
}
}



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Use-Wicket-as-a-REST-API-tp4660894p4660898.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org


Reply via email to