Another idea for URI templates

Hi all,

I don't have the URI template draft handy unfortunately (on a long flight), so I can't confirm this, but I think I found something useful that I don't believe the template draft currently handles.

If you have a template that includes "/{foo}", then the "/" is always inserted into the template regardless of whether or not "foo" is actually defined.  It might be nice to have the "/" be there only if "foo" is set.  Maybe something like "{?foo/}", which means:


-          If "foo" is not set, append the empty string.

-          If "foo" is set but empty, append "/" and the name "foo" only.

-          If "foo" is set to a string, append "/", then the name, then "=", then the value.

-          If "foo" is set to a list, append "/", then the name, then "=", then the list elements separated by ",".

-          If "foo" is set to a key-value set, append "/", then the first key, then "=", then the first value; for all remaining key-value pairs, append "&", the next key, then "=", then its matching value. (The name is not actually inserted into the template.)

So then a template of http://example.com/query.php{?foo?}<http://example.com/query.php%7b?foo?%7d> expands thus:


-          "foo" undefined: http://example.com/query.php

-          "foo" defined, but empty: http://example.com/query.php?foo

-          "foo" defined to string "bar": http://example.com/query.php?foo=bar

-          "foo" defined to list "a,b,c": http://example.com/query.php?foo=a,b,c

-          "foo" defined to key-value set "{a, 1}, {b, 2}, {c, 3}": http://example.com/query.php?a=1&b=2&c=3

Am I wrong, and the URI template spec handles this?  Or does this warrant some consideration and development?

Thanks,
-MSK

Received on Tuesday, 25 October 2011 09:48:04 UTC