3

I note that the last paragraph of RFC 3986 section 3.3 states:

Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents. For example, the semicolon (";") and equals ("=") reserved characters are often used to delimit parameters and parameter values applicable to that segment.

I know that the standard @Path annotation handles patterns like foo/{bar}/baz to pull "bar" as a parameter into the associated method.

What I have not been able to find is any mention of handling something like /foo/x,param1=baz/bar or /foo/x;param1=baz/bar where the param1 value "baz" would be passed to the associated method.

Has anyone seen anything like this?

Community
  • 1
  • 1
cWarren
  • 453
  • 5
  • 11
  • I don't think query parameters can be in the middle of a url. Only at the end – OneCricketeer May 20 '16 at 12:58
  • 3
    Your example looks like you want [matrix parameters](http://stackoverflow.com/a/26993356/2587435). – Paul Samsotha May 20 '16 at 13:01
  • 3
    Note that there is also the `@MatrixParam` annotation that you can use just like any other `@XxxParam`. – Paul Samsotha May 20 '16 at 14:22
  • Is there a way to split associate the matrix params with the path segment they came from: e.g. /x;foo=baz/y;foo=bar and associate foo=baz with the x segment and foo=bar with the y segment? – cWarren May 20 '16 at 14:29
  • 2
    You need to use the `PathSegment` as seen in the example I linked to. Each `PathSegment` comes with the path value and all the matrix parameters in a map – Paul Samsotha May 20 '16 at 14:35
  • If the matrix parameters suggestion was posted as a solution I would select it as the answer – cWarren May 22 '16 at 07:57

1 Answers1

-1

What you are referring here is hierarchical URI, which used specially in case where you have relation between resources.
Your URI shows bar and baz is related such that for a value of bar there is resource of baz.
Lets consider you want to pass {bar} value as xyz also want to pass some parameter value to baz end point.
So your URI should look like

/foo/xyz/bar?param=value

Hope this helps you.

Manoj
  • 59
  • 2