0

I have one class that extends org.restlet.Application class. Various requests are handled using this class, say:

  • /register
  • /login /listitem I perform all operations using POST request and manage all org.restlet.resource.ServerResource classes with annotation @Post("json").

My problem is if requests other than POST come into scenario I got an error like 405 Method Not Allowed. So how to handle other requests without explicitly write code for each annotation?

Hardik Bhalani
  • 863
  • 2
  • 8
  • 24

1 Answers1

0

I'm not sure to correctly understand your problem. When using Restlet, you need to explicitly define an annotated method for each HTTP method you want to support.

What do you exactly want to do?

Thierry

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • I thought there would be alternate way for not defining the methods that i am not going to use..if its compulsory than its fine – Hardik Bhalani Apr 02 '13 at 10:28
  • But POST is the only method you support, so a 405 Method Not Allowed response seems appropriate for the other methods. What would you want to be returned in those cases? – Andy Dennie Apr 02 '13 at 12:52
  • Yes, but 405 status code is what you'll have when you try to call not supported methods for a resource... This is the normal behavior. What do you expect in such case? – Thierry Templier Apr 02 '13 at 13:00
  • i want to do proper error handling since i am getting 405 only at browser side...i am not able to get this error code in the Application class ...and the ServerResource class is not going to handle my request since its passed through GET (in ServerResource i only implementd POST method)..so to overcome such scenario and proper error handling i need to ask (i expect proper exception at Serverresource class so that i can generate JSON response according to that exception) – Hardik Bhalani Apr 06 '13 at 09:48