views:

24

answers:

1

I started out looking at the JAX-RS plugin for grails and thought that was the way to go mainly because it was based on JSR-311 and I figure following standards is usually the smart thing to do. However, using Grail's UrlMappings it seems I basically achieve the same thing. I figure I'm missing something, however, we aren't doing anything overly complex. We basically just need to expose CRUD via an API. Example of doing the same thing with both versions:

JAX-RS:

@PUT
@Consumes(['application/json'])
@Produces(['application/json'])
Response putUser(User user) {
  user.save(flush:true)
  ok user
}

Grails:

def update = {
  def user = new User(params['user'])
  user.save(flush:true)
  render user as JSON
}

Obviously, this is an overly-simplified example and like I said, maybe I'm missing something important. Also, the nice thing about the Grails built in mechanism is I can utilize Content Negotiation along with it.

Anyone have any opinions on this?

+1  A: 

I had to make the same decision, and I found it just easier to use URL Mappings because the API was not that complex and there were a limited number of API calls that needed to supported.

If came down to what would be easier to maintain based on the LOE and the resources able to support the implementation.

Aaron Saunders
That's kind of how I'm leaning, Aaron. I suppose if things get more complex later, I can always change out the mechanism.
Gregg