I'd like to have a versioned REST api using an HTTP Request Header:
GET /someResource
Version: 1.0
Now if I have 2 versions of this resource, my JaxRS web application needs to be able to serve responses appropriate to either of the requested versions. As such I would expect the following classes to be part of my classpath:
@Path("/someResource")
public class SomeResourceV1 {
**snip**
}
and
@Path("/someResource")
public class SomeResourceV2 {
**snip**
}
Now I'd like to dispatch the request to one of these resource classes depending on the Version header. I'd assume this would be done using a servlet filter. But since I'm using Guice, I think what I'm looking for is a per request injector.
If request has Version 1.0 use injector with bindings for SomeResourceV1 otherwise if request has Version 2.0 use injector with bindings for SomeResourceV2
I think there is a way to get what I want by subclassing GuiceFilter, but I'm not entirely sure. Has anyone tried something like this before?