According to Extending Restful Controller
I Can create a SubClass of this RestfulController to become a Base controller class for every rest Controller I want.
Its OK subclassing this to a DIRECT resource controller.
Class BooksController extends RestfulController {
BooksController() {super(Book)}
But if instead I follow the grails DOC to create a base controller like this:
class MyRestController<T> extends RestfulController<T> {
static responseFormats = ['json', 'xml']
MyRestController(Class<T> domainClass) {this(domainClass, false)}
MyRestController(Class<T> domainClass, boolean readOnly) {
super(domainClass, readOnly)
}
I got an error:
Failed to instantiate [clash.MyRestController]: No default constructor found;
I tried putting this controller inside controllers folder or src folder.
Only works if I create a default constructor but it is not what I want. I don want this class to serve API for any domain class but instead I want to create new controllers extending this class.
class BooksController extends MyRestController {
BooksController() {super(Book)}