0

I want a GET endpoint api/v1/getNames to also bind to another application's GET endpoint user/getData. Please note the different Restlet Context here. Is there an efficient way to implement this?

quarks
  • 33,478
  • 73
  • 290
  • 513
oneinaminion
  • 21
  • 1
  • 3

1 Answers1

0

You would do something like this:

@Override
public Restlet createInboundRoot() {
  Router router = new Router(getContext())
  router.attach("api/v1/getNames", UsersServerResource.class); 
  router.attach("user/getData", UsersServerResource.class); 
}

If you want the server resource to be handled by both api/v1/getNames and user/getData endpoints. (That is, if I understand your question correctly)

And as a note, REST api endpoints usually should be noun-based, not verbs.

So your endpoint should be better be like:

router.attach("api/v1/names", UsersServerResource.class); 
router.attach("api/v1/users", UsersServerResource.class); 
quarks
  • 33,478
  • 73
  • 290
  • 513