Testing whether an actual URI matches a specific URI Template

r
now, it seems the goal is to be able to construct an actual URI
from a URI Template and a set of variable values.  For instance:

    http://example.com/~{username}/ + { username: me }
    => http://example.com/~me/

  But is it also intended to give the value of all variable parts
given a template and an actual URI?  As well of course whether an
actual URI does match or not a specific template.  For instance:

    http://example.com/~{username}/ + http://example.com/~me/
    => { username: me }

    http://example.com/~{username}/ + http://example.com/that/
    => <does not match>

  A particular use case would be a descriptor describing the
dispatching between several resources based on URIs.  E.g. the
web.xml descriptor in Java EE defines a link between URI (with a
specific format of URI patterns) and Java Servlet:

    <servlet-mapping>
       <servlet-name>ThatServlet</servlet-name>
       <url-pattern>/that/</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
       <servlet-name>UserServlet</servlet-name>
       <!-- cannot do something as precise as "~*" -->
       <url-pattern>/users/*</url-pattern>
    </servlet-mapping>

  Basically, when the server receives an HTTP request, on one
specific URI, it looks for the first match of the above mappings
and selects the corresponding servlet.  Using the URI Template
format, that would gives something like the following, setting
automatically the variable "username":

    <servlet-mapping>
       <servlet-name>ThatServlet</servlet-name>
       <url-pattern>/that/</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
       <servlet-name>UserServlet</servlet-name>
       <url-pattern>/~{username}</url-pattern>
    </servlet-mapping>

  This is of course only one example, but this can be generalized
to all situations where we want to resolve an actual URI to a
resource depending on a mapping based on URI Templates.

  Is it an interesting use case for the WG?

  Regards,

-- 
Florent Georges
http://fgeorges.org/



      

Received on Tuesday, 22 June 2010 17:50:27 UTC