Chainable JSGI Responses

Changes in RingoJS 0.10

RingoJS is a JavaScript runtime written in Java. We use it in various projects and it’s particularly suitable for Web applications which acts as API endpoint for a client-side application.

Last Monday I gave a short talk titled „The State of RingoJS“ about the recent 0.10 release and how to deploy a Ringo application on Google App Engine. Though there was not enough time to cover the new chainable JSGI response module and how easy it is to respond on a request. Especially if you write a server-side API for a modern JSON-based Web application with a framework like Backone, then the JSGI response module will be a time saver and easy to use.

Let’s say you hava a function which returns an entity stored on Google App engine. The id of the entity is a query parameter of the URL. Here is a code example how you can write such a function:

As you can see it’s very easy to create a JSON response for the request. And have you noticed the special syntax of the first catch block? Thanks to Ringo we can react on the class of the exception and return a 404 error instead of a more general error message. That’s just one feature which makes the integration of existing Java libraries, such as the Google App Engine for Java, very easy in Ringo.

Philipp Naderer-Puiu,