0

I am using spring and restlet in a project.

I am trying to implement automatic resource discovery. If user issues a get request like this, response should have links to the child resources as shown below.



Request :

GET

http://<host>:<port>/root/

Response :

http://<host>:<port>/root/v1

http://<host>:<port>/root/v2

http://<host>:<port>/root/v3



Request :

GET

http://<host>:<port>/root/v1

Response:

http://<host>:<port>/root/v1/resource1

http://<host>:<port>/root/v1/resource2

http://<host>:<port>/root/v1/resource3

and so on.

I explored restlet java docs but couldn't find any feature for automatic resource discovery.

The other options which i can think of now is to create each level as an endpoint and return the links to child resources but i am not sure if this is the correct way.

Is there such a feature available in restlet? If not what are the other options available in restlet to implement such a feature?

Thanks.

1 Answers1

0

You can have a look at the code of the org.restlet.ext.wadl or org.restlet.ext.apispark (only in master branch) extensions. The idea is to start with the Application "getInboundRoot" Restlet. In a recursive manner, detect if it is a filter (in this case, analyse the filter#getnext()" restlet), if it is a Router, loop over the Router#getRoutes and analyse the target Restlet. In case of a "Finder" instance this actually means there is a ServerResource attached. If not, this a pure Restlet that symple handles all requests.

user229044
  • 232,980
  • 40
  • 330
  • 338
Thierry Boileau
  • 866
  • 5
  • 8