I have a Grails 2.4.2 application that I want to communicate with another application, and this interaction should occur through a Rest service provided by Grails.
Today the way it is implemented I just inform .json at the end of the URL that it returns me the formatted data. However I would like to know how to handle these implementations to add the methods POST
, PUT
and DELETE
.
I did a search on the official documentation , so I got to following encoding:
UrlMappings.groovy
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
"/"(controller:"main")
"500"(view:'/error')
"/patrimonios"(resource:'Patrimonio')
}
}
When I run the application and access the http://localhost:8080/Patrimonio/patrimonios
link I have a blank page in return.
I tested the POST and DELETE methods through the POSTER addon and nothing happened as well.
So I would like to know how best to proceed to achieve the desired goal?
UrlMappings.groovy (EDITED)
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
"/"(controller:"main")
"500"(view:'/error')
"/api/patrimonio/"(controller: "PatrimonioController") {
action = [GET: "get"]
}
}
}