Restlet routing with query parameter

27 Views Asked by At

I'm facing an issue after upgrading the Restlet package from version 1.0.10 to 2.4 in a large legacy application.

We have a scenario where our application receives requests in the following two formats :

Get "/operations/arrivals/comp?COMP-ID=525&GRANULARITY=DAY"

Get "/operations/arrivals/comp?COMP-ID=525&dn=1234&GRANULARITY=DAY"

The mapping is defined as follows:

router.attach("/operations/arrivals/comp", compReport.class)
router.attach("/operations/arrivals/comp?{a}dn={b}", DNcompReport.class)

So, if the request has the 'dn' query string, it should be mapped to DNcompReport.class; if not, it would be mapped to compReport. This functionality worked well with the previous version of Restlet.

However, after upgrading Restlet, the mapping is not occurring correctly. Even if the request contains the 'dn' query string, it still maps to compReport.class.

While searching for a solution, I found many suggestions to set the matched query to true using route.setDefaultMatchingQuery(true). After doing this, only requests containing 'dn' are recognized as valid, and mapping occurs as expected for 'dn' requests. However, if we request '/operations/arrivals/comp?COMP-ID=525&GRANULARITY=DAY', it throws 'The server has not found anything matching the request URI'.

0

There are 0 best solutions below