Thursday, June 18, 2009

Simple REST server with Grails

I have recently worked on two small projects that need a simple data store for more intelligent clients. Choosing REST was a no-brainer after some discussion. Grails' HTML CRUD interface is a great template to start off with, but it lacks dealing with XML/JSON.


You can get all the scaffold templates with the command "grails install-templates". Edit src/templates/scaffolding/Controller.groovy similarly to this tutorial. To see the end result, generate the resulting code: "grails generate-controller Person"
NOTE: When editing a template, the code generated from the template can block the newly generation and cause errors you were not expecting!

Time for some fun

When you've got the scaffolding in place;

  • create a simple domain model in Groovy + Grails syntactic sugar (one-to-many relations)

  • create controllers for each domain class you want to expose. Use automatic scaffolding as much as possible

  • no need for an additional bulletpoint, thats all there is to it

The RFID-Server source code uses this approach

1 comment:

  1. This comment has been removed by a blog administrator.


Spam will be pruned