Closed gdrte closed 8 years ago
Sorry for chiming in late. As far as I could understand, the main goal is to have an easier/faster way to implement CRUDs, right?
If the answer is yes, maybe we could get away without inheritance (I could see some complications with this implementation, in particular, regarding consistency checks between implementation of the super class and sub classes). @jknack @gdrte have you guys thought of using @Crud Annotation? Something like:
@CrudController(methods={CREATE, READ, UPDATE, DELETE}, dao = UserDao.class) public class UserController { ,,, }
Then we would have some processor that implements CRUD in a very simple way.
We could use Guice to create a new instance of UserDao.
Any thoughts?
@danielfireman I am afraid, the implementation will be complex. How should it support, if I want all my CRUDs are non-blocking?
Agreed with @gdrte.
@danielfireman what do you mean with:
I could see some complications with this implementation, in particular, regarding consistency checks between implementation of the super class and sub classes
can you provide an example?
Jooby doesn't support extending routes. The usage is, define some common API(CRUD) in Abstract route and extend this router to add additional APIs. What exactly I mean is as follows. `@RestController abstract public class AbstractController {
/*
* List the Models
* @return List, a list of Models.
/
@RequestMapping(method = RequestMethod.GET)
public List list() {
return dao.find().asList();
}
/
* Get the Model given by an ID
* @return Model.
*/
@RequestMapping(method = RequestMethod.GET,value="/{id}")
public Model findOne(@PathVariable final String id) {
return dao.get(new ObjectId(id));
}
} @RestController @RequestMapping("/api/user") public class UserController extends AbstractController {
}`