Testing whether an actual URI matches a specific URI Template

[[ sorry for reposting, the original email seems to have been
   truncated by my MUA ]]

  Hi,

  I have a comment about the URI Template draft document 04.  For
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 patrticular 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:54:21 UTC