kamaci
kamaci

Reputation: 75257

Rewriting Java Controller Class with Grails REST

I have implemented a REST application with Spring at Java. An example of GET and DELETE requests are as follows:

@RequestMapping(method = RequestMethod.GET)
public
@ResponseBody
List<Configuration> getAllConfigurationsInJSON() {
    return new ArrayList<Configuration>(configurationMap.values());
}

@RequestMapping(value = "{systemId}", method = RequestMethod.DELETE)
public void deleteConfiguration(HttpServletResponse response, @PathVariable long systemId) throws IOException {
    if (configurationMap.containsKey(systemId)) {
        configurationMap.remove(systemId);
        response.setStatus(HttpServletResponse.SC_OK);
    } else {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
}

I am searching about Grails and want to rewrite my controller with Grails. I read some articles and it shows that there is no need to write that annotations at Grails. I will just define my clousers and it will render my response to JSON object as like my Spring applicaiton. How can I implement them with closures? (I use IntelliJ IDEA 10.3)

Upvotes: 0

Views: 281

Answers (1)

Bozho
Bozho

Reputation: 597432

There is nothing in this code that can make use of closures.

In grails it may look the same, or you can put the url mappings in UrlMappings.groovy

Upvotes: 1

Related Questions