As always, wikipedia is a perfect place to find information about this: link
More specifically speaking, when doing this in a grails application. Is very important to set up the path that the URL mapping is going to follow. We set this in the URLMappings.groovy file. Inserting the following code for each new route you want to define:
"/rest/url/**" (controller:"YourRestController", action:"method") {
action = [GET: "method"];
}
One thing I found out while doing this, is that you are not supposed to put the entire: controllerNameController class name, just the name itself: controllerName.
Once the route to our API method is set, we can define the logic we want it to deliver. Regarding HTTP statuses, in grails we do as follow (at least I do):
- response.status = 200; // 200 OK. Just to set the status.
- render(status:204, text:'Extra information about the status') // 204 NO CONTENT. Status + information
Cheers!