0

Over the past week, I've been struggling to adapt a Grails application to use the REST architecture. Problem is, I've had nothing but trouble throughout.

For this application, the choice between using XML and JSON literally came down to a coin flip. Neither format offered much over the other, so I went with XML.

Writing the URL redirects and the controller methods was relatively easy and got me interested. The problems came when actually doing stuff with the new controller functions. Specifically, two major issues came to light

First, the list view of an object works with the regular CRUD method. Adapting to REST required executing a query to get all objects, count them up and render the output as both HTML and XML using the withFormat method.

HTML view shows absolutely nothing in the way of listings, but the XML tree shows up when I comment out the HTML section in withFormat. So I know that part's working.

Secondly, what to do when a premature end of XML file exception comes at you when its the machine creating the XML in the first place?

At this point, to me at least, REST seems like more of a solution in search of a problem. It essentially co-opts the HTTP functions for its own use, when controller redirects seem to work fine.

Is it a scalability adaptation?

0

REST is not a solution, it's a convention, and as such, it is subjective.

Which is more readable?

REST:

PUT /users/profile/1234
{userName:fooBar,...}

Non REST:

POST /userController.go?action=updateUser&userId=1234&userName=fooBar...

It's up to you to decide what you prefer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.