On 10/04/2013 17:43, Joakim Erdfelt wrote:
> A question about the URI template matching rules.
>
> Example:
> @ServerEndpoint with URI template of "/a/{var}"
>
> Some request variants.
>
> Request "/a/b"
> This is the clear and obvious case, pretty normal. Well documented in
> the spec.
> "var" == "b"
+1
> Request "/a/b/"
> Should this match?
> If so, then "var" == "b", right? (not "var" == "b/")
I took a look at RFC3986. The short version is that this is up to us.
I do think that var == b/ is definitely the wrong way to go.
Beyond that, it depends if we consider /a/b and /a/b/ to be equivalent.
I am leaning towards saying that /a/b/ does not match /a/{var}
> Request "/a/"
> Should this match?
> If so, then "var" == ""? or "var" == null?
For consistency with the previous example yes it matches. I would opt
for var = "".
> Request "/a"
> Should this match?
> If so, does it follow the same behavior as "/a/" and have
> "var" == ""? or "var" == null?
Again, being consistent with the previous examples this would not match.
Taking this a little further how about the following:
/a/{var1}/{var2}
and
/a//c
I'd need to check but I suspect that Tomcat will normalise this is to
/a/c which won't match but ignoring this problem and following the
scheme above this would result in:
var1 = ""
var2 = "c"
What do you think?
Mark