Baz Baz - 1 year ago 144
reST (reStructuredText) Question

Restlet URL/path pattern mismapping

I'm developing a REST API using Restlet.

So far everything has been working just fine. However, I now encountered an issue with the

mapping of URL to

I've got the following scenario:

  • GET
    returns a list of all cars

  • GET
    returns details about the car with id 1

  • GET
    should run a search across all cars with some parameters

The first two calls work without any problems. If I try to hit the third call though, the Restlet
somehow maps it to the second one instead. How can I tell Restlet to instead use the third case?

My mapping is defined as follows:

router.attach("/car", CarListResource.class);
router.attach("/car/{id}", CarResource.class);
router.attach("/car/advancedsearch", CarSearchResource.class);

is never invoked, but rather the request ends up in

The router's default matching mode is set to
, so that can't be causing it.

Does anyone have any further suggestions how I could fix it?

Please don't suggest to use
with the parameters instead, as there's already another kind of search in place on that level. Also, I'm not in control of the API structure, so it has to remain as it is.

Baz Baz
Answer Source

I was able to solve this by simply reordering the attach statements:

router.attach("/car/advancedsearch", CarSearchResource.class);
router.attach("/car",                CarListResource.class);
router.attach("/car/{id}",           CarResource.class);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download