0

I'd like to know if it's possible to have two different URI's in the same (Rest) @Path using regex or something else.

Eg.:

@Path("{path: (/foo1|/foo2)}")
public class Service {
    ...
}

Or something like that.

I'd like to call something like:

http://localhost/foo1
http://localhost/foo2

But using the same class.

I'd appreciate any help.

Doug LN
  • 132
  • 2
  • 11

1 Answers1

0

Probably (I didn't try it myself). From The RESTful Web Services Developer's Guide (this is not your specific case...the regex is left as an exercise for the reader):

If it is required that a user name must only consist of lower and upper case numeric characters, it is possible to declare a particular regular expression that will override the default regular expression, [^/]+?. The following example shows how this could be used with the @Path annotation.

@Path("users/{username: [a-zA-Z][a-zA-Z_0-9]}")

This example is from The @Path Annotation and URI Path Templates in the guide referenced above.

Paul
  • 19,704
  • 14
  • 78
  • 96