What’s next

June 18, 2009

Simple REST server with Grails

Filed under: Architecture,Grails,Groovy — stigl @ 11:36 am
Tags: , , ,

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.

Prerequisits

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

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: