gServ is a tool for creating and deploying REST based services using Groovy without the
hassle of a container (JBoss, Tomcat, etc.) . Using gServ, you can easily define
REST resources as Groovy scripts or embed gServ in your application. gServ is
perfect for creating lightweight micro services.
gServ can be used in two ways <br/><h3>Features:</h3>
<ul class="docs-content">
<li>Container Free
<li>Serve static files
<li>Serve Groovy script as REST resources
<li><a href="https://github.com/javaConductor/gserv/wiki/gServ-HATEOAS"> HATEOAS Support</a>
<li>Easy Content Negotiation
<li>Plugin API
<li><a href="https://github.com/javaConductor/gserv/wiki/gServ-Framework">Embeddable</a>
<li><a href="https://github.com/javaConductor/gserv/wiki/gServ-Standalone">Standalone Mode</a>
<li>CORS support
<li>Compression support
<li>ETag support
<li>Basic Authentication
<li> HTTPS
</ul>
<h3>Requirements:</h3>
<ul><li>Java JDK 1.6+</li>
<li>Groovy 2.3+ (Framework only)</li>
</ul>
<div class="docs-content">
<h3>Basic Concepts</h3>
<table width="90%" class="docs-content">
<tr><th>Term</th> <th>Meaning</th></tr>
<tr><td>Action</td> <td>HTTP request handler for a particular path/query/method combination. </td></tr>
<tr><td>Resources</td> <td>Resources define actions for a particular root path (eg. /books) and its sub-resources (eg. /books/bestSellers). </td></tr>
<tr><td>Server Config</td><td>The config encapsulates any resources, actions, filters, and plugins. </td></tr>
<tr><td>Server Instance</td><td>This is the actual server instance that will listen to the specified port and handle
requests based on its configuration.</td></tr>
</table>
</div>
[Framework](https://github.com/javaConductor/gserv/wiki/gServ-Framework)
[Standalone](https://github.com/javaConductor/gserv/wiki/gServ-Standalone) #Simple Examples
Creating REST Resources | |
---|---|
| |
The root path is passed to the GServ.resource() method along with a closure defining the actions for the resource. | |
Creating a Server Instance | |
| |
The http() method creates a GServInstance that can later listen on a port and handle HTTP requests. This server instance defines static roots usually used for templates for single-page apps and a single FAQ page. Then, after the server instance is returned from the http() method, we can immediately call start(8080) on it. | |
Adding Resources to a Server Instance | |
|
|
A server instance can be created by simply adding resources. Here we add our 2 resources: bkResources and userResources. Now, all URIs related to both resources are available once the instance is started. This instance also defines a static_root which tells gserv where to find static files such as the FAQ page which should be at /public/webapp/App.faq.html. |