Re: URI matching question
Thierry, It works nicely. I create a couple of routes for each resource. Does it make sense to move some of this back to the core. cheers /jima Jim Alateras wrote: cool, i'll give it a go today. cheers /jima Thierry Boileau wrote: Hi Jim, as a workaround, you can define 2 routes like this : //Serves only http://localhost:6080/appcontext/version route = [...]attach(/version, ...); route.getTemplate().setMatchingMode(Template.MODE_EQUALS) //Serves only http://localhost:6080/appcontext/version? // andhttp://localhost:6080/appcontext/version?nam1=value1... route = route = [...]attach(/version?{MyQuery}, ...); route.getTemplate().getVariables().put(MyQuery, new Variable(Variable.TYPE_URI_QUERY, , false, false)); best regards, Thierry Boileau Hi Jim, From an URI specification point of view, there is no difference between a URI with or without a query string. The query string can have a fixed format or use a common name/variable format. The general routing algo respects the initial URI submitted and tries to match the start of the remaining URI available. So, in your case the EQUALS mode doesn't works because you don't know in advance which query parameters are available or in which order. So you need to use the default STARTS_WITH mode. Then, inside your Resource you should test that the Request.getResourceRef().getRelativeRef() is equals to .. But I agree that this can be a bit cumbersome to test this in all case. It could be easier to have a property of a router indicating whether or not the query should be taken into account during the URI template matching: http://restlet.tigris.org/issues/show_bug.cgi?id=314 Best regards, Jerome -Message d'origine- De : Jim Alateras [mailto:[EMAIL PROTECTED] Envoyé : lundi 28 mai 2007 15:15 À : discuss@restlet.tigris.org Objet : URI matching question I have a restlet application with a single resource mapped to /version. I deploy the application in jetty and can access the resource correctly by entering the uri localhost:6080/appcontext/version but I also end up with the same resource when i enter localhost:6080/appcontext/versionbah. I have tried using something like the following route.getTemplate().setMatchingMode(Template.MODE_EQUALS) but then all my GETS with query strings are not processed correctly Is there something more that I need to do. cheers /jima
Re: URI matching question
Hi Jim, as a workaround, you can define 2 routes like this : //Serves only http://localhost:6080/appcontext/version route = [...]attach(/version, ...); route.getTemplate().setMatchingMode(Template.MODE_EQUALS) //Serves only http://localhost:6080/appcontext/version? // andhttp://localhost:6080/appcontext/version?nam1=value1... route = route = [...]attach(/version?{MyQuery}, ...); route.getTemplate().getVariables().put(MyQuery, new Variable(Variable.TYPE_URI_QUERY, , false, false)); best regards, Thierry Boileau Hi Jim, From an URI specification point of view, there is no difference between a URI with or without a query string. The query string can have a fixed format or use a common name/variable format. The general routing algo respects the initial URI submitted and tries to match the start of the remaining URI available. So, in your case the EQUALS mode doesn't works because you don't know in advance which query parameters are available or in which order. So you need to use the default STARTS_WITH mode. Then, inside your Resource you should test that the Request.getResourceRef().getRelativeRef() is equals to .. But I agree that this can be a bit cumbersome to test this in all case. It could be easier to have a property of a router indicating whether or not the query should be taken into account during the URI template matching: http://restlet.tigris.org/issues/show_bug.cgi?id=314 Best regards, Jerome -Message d'origine- De : Jim Alateras [mailto:[EMAIL PROTECTED] Envoyé : lundi 28 mai 2007 15:15 À : discuss@restlet.tigris.org Objet : URI matching question I have a restlet application with a single resource mapped to /version. I deploy the application in jetty and can access the resource correctly by entering the uri localhost:6080/appcontext/version but I also end up with the same resource when i enter localhost:6080/appcontext/versionbah. I have tried using something like the following route.getTemplate().setMatchingMode(Template.MODE_EQUALS) but then all my GETS with query strings are not processed correctly Is there something more that I need to do. cheers /jima
Re: URI matching question
cool, i'll give it a go today. cheers /jima Thierry Boileau wrote: Hi Jim, as a workaround, you can define 2 routes like this : //Serves only http://localhost:6080/appcontext/version route = [...]attach(/version, ...); route.getTemplate().setMatchingMode(Template.MODE_EQUALS) //Serves only http://localhost:6080/appcontext/version? // andhttp://localhost:6080/appcontext/version?nam1=value1... route = route = [...]attach(/version?{MyQuery}, ...); route.getTemplate().getVariables().put(MyQuery, new Variable(Variable.TYPE_URI_QUERY, , false, false)); best regards, Thierry Boileau Hi Jim, From an URI specification point of view, there is no difference between a URI with or without a query string. The query string can have a fixed format or use a common name/variable format. The general routing algo respects the initial URI submitted and tries to match the start of the remaining URI available. So, in your case the EQUALS mode doesn't works because you don't know in advance which query parameters are available or in which order. So you need to use the default STARTS_WITH mode. Then, inside your Resource you should test that the Request.getResourceRef().getRelativeRef() is equals to .. But I agree that this can be a bit cumbersome to test this in all case. It could be easier to have a property of a router indicating whether or not the query should be taken into account during the URI template matching: http://restlet.tigris.org/issues/show_bug.cgi?id=314 Best regards, Jerome -Message d'origine- De : Jim Alateras [mailto:[EMAIL PROTECTED] Envoyé : lundi 28 mai 2007 15:15 À : discuss@restlet.tigris.org Objet : URI matching question I have a restlet application with a single resource mapped to /version. I deploy the application in jetty and can access the resource correctly by entering the uri localhost:6080/appcontext/version but I also end up with the same resource when i enter localhost:6080/appcontext/versionbah. I have tried using something like the following route.getTemplate().setMatchingMode(Template.MODE_EQUALS) but then all my GETS with query strings are not processed correctly Is there something more that I need to do. cheers /jima
RE: URI matching question
Hi Jim, From an URI specification point of view, there is no difference between a URI with or without a query string. The query string can have a fixed format or use a common name/variable format. The general routing algo respects the initial URI submitted and tries to match the start of the remaining URI available. So, in your case the EQUALS mode doesn't works because you don't know in advance which query parameters are available or in which order. So you need to use the default STARTS_WITH mode. Then, inside your Resource you should test that the Request.getResourceRef().getRelativeRef() is equals to .. But I agree that this can be a bit cumbersome to test this in all case. It could be easier to have a property of a router indicating whether or not the query should be taken into account during the URI template matching: http://restlet.tigris.org/issues/show_bug.cgi?id=314 Best regards, Jerome -Message d'origine- De : Jim Alateras [mailto:[EMAIL PROTECTED] Envoyé : lundi 28 mai 2007 15:15 À : discuss@restlet.tigris.org Objet : URI matching question I have a restlet application with a single resource mapped to /version. I deploy the application in jetty and can access the resource correctly by entering the uri localhost:6080/appcontext/version but I also end up with the same resource when i enter localhost:6080/appcontext/versionbah. I have tried using something like the following route.getTemplate().setMatchingMode(Template.MODE_EQUALS) but then all my GETS with query strings are not processed correctly Is there something more that I need to do. cheers /jima