Building a quick and dirty REST API with Ratpack script; can't figure out how to allow DELETE from all origins.
I've tried setting headers within delete
, and using all
(as in sample code.) Sending DELETE with curl, postman, everything always returns 405. Am I missing something simple?
@Grapes([
@Grab('io.ratpack:ratpack-groovy:1.6.1')
])
ratpack {
handlers {
all {
MutableHeaders headers = response.headers
headers.set("Access-Control-Allow-Origin", "*")
headers.set("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE")
next()
}
post("product") {
...
}
get("product/:id") {
...
}
delete("product/:productId") {
// always returns 405
...
}
}
}