Hi all,
I've used a regular expression in @Path to achieve overloading and at first I thought it was really neat, but overloading methods is usually not good practice. Does the same apply to RESTful web services? Is there a better way to achieve this using JAX-RS?
So I can now call my getProject REST service by /project/ProjectNumber1000 or /project/12345
@Path("/project")
public class ProjectPropertiesResource
{
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{name : [a-zA-Z]+}")
public Response getProjectPropertiesByName(@PathParam("name") String name)
{
...
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id : \\d+}")
public Response getProjectPropertiesById(@PathParam("id") long id)
{
...
}
}