POST /options/somewhere
当我在下面创建 grails 2.2.4 应用程序时,我看到了对OPTIONS /options/somewhere
.
有什么方法可以对 OPTIONS 请求调用控制器操作吗?
POST
有效和无效的应用程序OPTIONS
:
$ 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.")
}
}