users@jersey.java.net

[Jersey] Regex matches for path segments

From: Ben Hood <0x6e6562_at_gmail.com>
Date: Fri, 10 Aug 2012 14:41:22 +0100

Hi,

I'm using Jersey 1.13 and I want to configure my resources to match on
multiple path segments. I have been able to get this to work by
configuring my resource thusly:

@Path("/foo")
class SomeResource {

  @Path("/{path:.+}/bar")
  def method1(@PathParam("path") space:String) = {
    // do something here
  }

  @Path("/{path:.+}/baz")
  def method2(@PathParam("path") space:String) = {
    // do something here
  }
}

However, I'd like pull the {path:.+} match up to the class level, e.g.:

@Path("/foo/{path:.+}")
class SomeResource {

  @Path("/bar")
  def method1(@PathParam("path") space:String) = {
    // do something here
  }

  @Path("/baz")
  def method2(@PathParam("path") space:String) = {
    // do something here
  }
}

When I do the latter, Jersey fails to match the route and returns a 405.

Is there something I'm doing wrong here?

Cheers,

Ben