Reputation: 8738
When I create the grails 2.2.4 app below, I see responses to POST /options/somewhere
but not to OPTIONS /options/somewhere
.
Is there some way to invoke a controller action on OPTIONS requests?
App where POST
works and OPTIONS
doesn't:
$ grails create-app options
$ grails create-controller api
UrlMappings.groovy:
class UrlMappings {
static mappings = {
"/somewhere" (controller: "api", parseRequest: true) {
action = [OPTIONS: "getOptions", POST: "saveStuff"]
}
}
}
ApiController.groovy:
package options
class ApiController {
def getOptions() {
render("Your options await.")
}
def saveStuff() {
render("Stuff saved.")
}
}
Upvotes: 1
Views: 1028
Reputation: 1266
Try this code:
"/somewhere" (controller: "api", parseRequest: true) { //controller name begins with a lowercase letter
action = [OPTIONS: "getOptions", POST: "saveStuff"]
}
I use grails 2.0.3 and it do not work as I expected. But should work for latest grails version (2.3). Pls see related bug.
Upvotes: 1