Reputation: 11
I've got two controllers. PollController and api.PollApiController.
My PollController is just a normal controller. The API-Controller inherits the RestfulController:
class PollApiController extends RestfulController {
static responseFormats = ['json', 'xml']
PollApiController() {
super(Poll)
}
}
These are my URL-Mappings:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
"/api/poll"(resources:'poll', controller:'pollApiController')
}
}
My problem is that every time I do a /api-Call grails runs the PollController instead of PollApiController. I can check it if I alter the PollController. It's the first time I work with the RestfulController, what am I doing wrong?
Upvotes: 0
Views: 528
Reputation: 2249
When you map to a RestfulController
, you don't need the controller
parameter. Instead, resources
should be set to the base name of your (Restful) Controller.
"/api/poll"(resources: 'pollApi')
For more detail, see: http://grails.org/doc/latest/guide/single.html#restfulMappings
Upvotes: 1