Hi!
I've been trying to make a Jersey app that takes the following structure from the path:
Example 1 (http:// omitted due to stackoverflow restrictions) example.com/source/{source-id}/ example.com/source/
With code (error handling and unneeded code omitted):
With code (sum up): @Path("/source/") public class SourceREST { ... @GET public Response getSource() { return Response.ok("Sources List (no field)").build(); }
@GET @Path("/{source-id}") public Response getSource(@PathParam("source-id") String sourceID) { return Response.ok("Source: " + sourceID).build(); }
}
It works fine.
Example 2: example.com/data/{source-id}/{info-id}/ example.com/data/{source-id}/
With code (error handling and unneeded code omitted):
@Path("/data/") public class DataREST { ...
@GET @Path("/{source-id}") public Response getContext(@PathParam("source-id") String sourceID) { return Response.ok("Source: " + sourceID + " Last ContextInfo").build(); }
@GET @Path("/{source-id}/{data-id}") public Response getContext(@PathParam("source-id") String sourceID, @PathParam("data-id") String dataID) { return Response.ok("Source: " + sourceID + " Data: " + dataID).build();
} }
In example 2, I can access an URL like example.com/data/111/222/ fine, but trying to get hexample.com/data/111/ gives me a 405 Error Code (Method Not Allowed). I've tried also to make a whole method that checks if {data-id} is empty or blank and in that case process the petition as in the first method, but doesn't work either.
Any idea?
Thanks!