Hi Sven, Le 12 sept. 2014 à 11:59, Sven Van Caekenberghe a écrit :
Hi Christophe,
On 12 Sep 2014, at 10:28, Christophe Demarey <christophe.demarey@inria.fr> wrote:
Hi,
I use Zinc-Rest and it works like a charm, really simple to quickly get something working. I have a question about URL pattern matching that is used to dispatch request to the right handler. I want to have following URLs: /foo/* /foo/latest I defined 2 handlers with following patterns: #('foo' '*') #('foo' 'latest')
I was expecting that the more precise handler was chosen but it was the generic handler (with '*'). Is there a way to do that? It is not blocking because I can use the same handler to manage both patterns but I would prefer to have them separated as the semantic is not the same.
Regards, Christophe.
My first answer would indeed also have been to handle both cases in one call (I did similar things in my projects). But now that you mention it, I think this can be fixed quite easily. Have a look at the following version:
=== Name: Zinc-REST-SvenVanCaekenberghe.16 Author: SvenVanCaekenberghe Time: 12 September 2014, 11:55:02.020483 am UUID: 6421d8be-c7c8-44fc-8958-121cc86ae93e Ancestors: Zinc-REST-SvenVanCaekenberghe.15
ZnCallHierarchyRestUriSpace>>#match: now uses #order to sort auto matched REST call subclasses - a lower order call will be matched before a higher order call. ===
By default, calls inherit order 50, to make move one call earlier in the matching process, override #order with a lower number.
Indeed, it does the trick with only a few changes :) I wonder if it would be a good idea to give a default lower priority (ex: 20) if the pattern ends with a '*'. It could be done in the order method. I think you will never had to override priority this way but it has a little CPU overhead. Thanks for the quick feedback. It looks like functionality on-demand :) Christophe