Supporting sub resource locators
Consider it a feature request.
Can you please show a simple use case?
I read the docs about locators, but I'm not sure it's possible to support them. At least, with h2 involved. Maybe, if sub-resource would be injected directly as a simple guice-managed bean it would be possible to use it as sub resource, but it must be verified:
@Inject SubResource sub;
@Path("sub") public class<SubResource> getSub() {
return sub;
}
Anyway, need to know what was the exact problem in your case and then I could look for possible solutiuon.
The problem:
// Kotlin
// API module
@Path("/users")
interface UsersResource {
@GET
fun list(): List<User>
@Path("/{id}")
fun get(@PathParam("id") id: String): UserResource
}
interface UserResource {
@GET
fun get(): User
}
// Implementation (dropwizard)
class MyUserResource @Inject constructor(
private val injector: Injector
): UsersResource {
override fun list(): List<User> { ... }
// this is boilerplate. can we get rid of it somehow?
override fun get(id: String): UserResource =
UserResource(id).apply { injector.injectMembers(this) }
}
Thank you for the example. I will look what I can do
Thanks. I guess an alternative would be to support sub resources (like your example) with the Class object syntax.