Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Custom REST path
Custom REST path [message #1723001] Wed, 10 February 2016 18:31 Go to next message
Dan Cunningham is currently offline Dan CunninghamFriend
Messages: 44
Registered: March 2014
Member
I'm working on a binding that needs to expose JSON and XML web services. This was easy enough to do by implementing RESTRsource and using JAXRS annotations. So I have a working REST endpoint at /rest/myapp . Life is good!

Unfortunately the device that consumes this web service is hard coded to hit a specific URL, so in this case it wants to hit /myapp and not /rest/myapp.

What I would like is to keep using JAXRS, but register my web service to something not "/rest/...." I can see how to register a custom servlet to any path, but I really want to keep using JAXRS annotations and not have to manually parse and format request/responses. I'm stumped how to do this.
Re: Custom REST path [message #1723331 is a reply to message #1723001] Sun, 14 February 2016 14:21 Go to previous messageGo to next message
Karel Goderis is currently offline Karel GoderisFriend
Messages: 198
Registered: March 2014
Senior Member
Dan,

Could this not be done by adding the @Path("/myapp") annotation to your root resource class?

Karel
Re: Custom REST path [message #1723360 is a reply to message #1723331] Mon, 15 February 2016 06:51 Go to previous messageGo to next message
Dan Cunningham is currently offline Dan CunninghamFriend
Messages: 44
Registered: March 2014
Member
using the Path annotation will append it to the current ROOT base path which is set to /rest. The only way I could find to bypass this was to use "httpService.registerServlet" and use a plain old HttpServlet. In the end the functionality is the same, I just dislike handling all the GET/PUT/POST logic and path parsing by hand.
Re: Custom REST path [message #1723368 is a reply to message #1723360] Mon, 15 February 2016 08:17 Go to previous messageGo to next message
Karel Goderis is currently offline Karel GoderisFriend
Messages: 198
Registered: March 2014
Senior Member
mmh.... can't you combine the two approaches? do a registration as a servlet, and use the annotations on the other classes? I presume you dislike it because you use variable paths and alike in the annotations?

Personally I have done the CalDAV server part through the "classic" httpService registration and by overriding methods, and it was relatively easy to do once you get the mechanics of it, but I understand your point of view Wink
Re: Custom REST path [message #1723901 is a reply to message #1723368] Fri, 19 February 2016 03:04 Go to previous message
Dan Cunningham is currently offline Dan CunninghamFriend
Messages: 44
Registered: March 2014
Member
Web servlet annotation is probably possible, but as you pointed out its the path parsing which is painful, and this is where jaxrs would have looked much prettier Wink
Previous Topic:Preferred way of instantiating DiscoveryService
Next Topic:Discovery Service
Goto Forum:
  


Current Time: Fri Apr 26 22:40:46 GMT 2024

Powered by FUDForum. Page generated in 0.03538 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top