CoreREST, is a kind of "PaaS"(Platform as a Service), which runs on Google AppEngine, which allows users to create their own lightweight "WebServices" based on REST approach using Groovy, and as sooner as possible with Ruby(powered by JRuby). I also will add many out-of-the-box APIs, such as: Smooks, and XStream, thus will possible: Transform, Convert and create really rich Services.
I used RestEasy 2.0, the JBoss implementation for JAX-RS standard, led by Bill Burke, which runs smoothly on Google AppEngine. I also, decided use another JEE6 standard in GAE: JSF 2.0, which to be honest: Without Seam, JSF seems to be a "Barbacue without salt", but in the end, it is running pretty well.
For persistence, as Google uses BigTable, a noSQL Implementation, the JPA Provider recommended by Google I really didn't liked, so I am using Objectify, which for me was more pleasant and easy to use.
In this first blog entry, I will just let you create and expose a basic "Service" in CoreRest. To do that, see the following instructions:
1- Open http://corerest.appspot.com
2- Click on Groovy logo icon
3 - Fill the following information:
3.1 - Script Name: This is the script name, which will be a kind of "endpoint name", so it will be the key for service invocation, put any simple name for it, your name for instance.
3.2 - URL Mapping - This is the URI that you want for for your service, you will put: /{firstname}/{lastname} .
3.4 - And the Source, will be the groovy script:
String response = lastname.toUpperCase() + ", "+ firstname; return response;
3.5 - Click on "Save Script"
Well, what is happening behind the scenes:
a) the URI is the extension for the "endpoint name", and the location where you will add the variables, exactly as you do according the standard on JAX-RS. In the URL: /{firstname}/{lastname}, we will have 2 variables available for Scripting context, besides the variable "response", which is the variable to return the response as a String, although CoreRest will support some Media types, I am still working on it, once it is totally possible using RestEasy.
To test you script, you just may call you service according the following URL:
http://corerest.appspot.com/service - (Service is the ROOT for endpoints)
http://corerest.appspot.com/service/tutorial/Edgar/Silva
Next Steps: I will try work on it, improve the UI and the user experience. I would like to say thanks to eXo Platform, for the Groovy Syntax hightlight, and Alexandre Porcelli that helped me to not use Java Regular Expressions and make my code easier :), and Eder Magalhães that tested CoreRest with me last night.
I sooner I get this code not so dirty though, I will publish and let it opensource somewhere, maybe GitHub, once I could at least to do my first commit there without any error :).
No comments:
Post a Comment