There are two ways in which we can bind our actions to a particular protocol
-
First one is to bind the actions to protocol in the declaration, in the controller
class UserController { static allowedMethods = [createUser: "POST", editUser: "PUT", deleteUser: "DELETE", getUser: "GET"] def createUser(){ ... } .... }
-
Second one is to bind the actions to protocol in the UrlMapping
class UrlMappings { static mappings = { ..... "/user/$id(.${format})"(controller:"user", parseRequest:true){ action = [DELETE:"deleteUser", GET:"getUser", PUT:"editUser"] } "/user(.${format})"(controller:"user", parseRequest:true){ action = [POST: "createUser"] } ... } }
More From Oodles
Ready to innovate? Let's get in touch
Request for Proposal
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Ashish Sharma
Ashish is a bright Groovy and Grails developer and have worked on development of various SaaS applications using Grails technologies. Ashish likes PC games and works out at Gym in his free time.