Tiny REST Server

John Bester

Welcome to Tiny REST wiki!

Tiny REST is a small Java based REST server that allows a Java programmer to easily create a REST server. A new server can be created by simply copying a sample project class and implement a handler class. This should not take more than 5 minutes. The server can use reflection to make public functions in a handler class available as HTTP REST functions. The simplest way to write a function is to take a single RestRequest argument. The request object provides the programmer with easy access to the HTTP query and header and also provides methods to write back responses to the output stream. POST bodies can be parsed automatically and there are methods to format objects as HTTP content as well.

The only required library is log4j which is distributed under the Apache Licence 2.

A service can easily be created using the Java Service Wrapper from Tanuki Software for which there are commercial and community editions available.

Download the source and have a look at the example package. It provides you with sample code to create a service. By simply taking out the reference to WrapperListener and @Override annotations, you can run the example as a stand alone application without having the service wrapper library.

The example provides methods that shows how to do GET and POST with text and xml.

  • HTTPS is now also enabled. By using SecureRestServer in stead of RestServer, your service can now listen for https requests.
  • Different service wrappers can be used to make your implementation an operating system independent service:
  • You can now use annotations to define your REST services - please see example.
  • You can also define your services in a configuration file in stead of writing a service class. There is a demo configuration file included (cfg/test.xml). You can use it by using RestServer class as main class and sending the following parameters to it -cfg cfg/test.xml (replace with path to your configuration file)

If you find this project at all helpful, please contribute 5 USD to help us improve the product.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="SWKNDKAQSR5M4"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> </form>

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks