Overview

RouteMaster a simple WebServer and router for Java.

Routemaster is a library that can be included to extend nanoHTTPd with additional functionality to include simple and RESTful routes. In itself it is not runnable, and requires at least the org.nanohttpd:nanohttpd library to be run.

There is an example jar which includes a complete runnable which can be found under the routemaster-templar.jar artefact in the github releases section. This includes all components to run the server.

There are two major ideas that the documentation relies on.

  1. Servants, and
  2. Handlers

Servants

Throughout this documentation we refer to the implementation classes as Servants - which either extend the Routable, or RestRoutable abstract classes.

All interfaces reside in the synapticloop.nanohttpd.router package.

Handlers

Handlers allow you to extend the functionality of routemaster to provide additional parsers for specific functionality. Included within this package is the templar handler synapticloop.nanohttpd.handler.TemplarHandler. This can be added to the configuration easily:

# Now for some handlers - this is for the templar handle (bound to *.templar)

handler.templar=synapticloop.nanohttpd.handler.TemplarHandler

you probably want to have a look at the quick start section to get up and running and understand the core framework.

Simple Router

When you just need a simple router in java where you take care of all of the details. Just implement the synapticloop.nanohttpd.router.Routable interface and over-ride the method(s) that you want to respond to.

REST-ful Router

When you just need a simple RESTful router in java, just implement the synapticloop.nanohttpd.router.RestRoutable interface and over-ride the method(s) that you want to respond to.

Static File Listing Serving

When you just want to serve up a directory listing from the root directory, there is a simple servant to do it for you.

Static File Serving

When you just want to serve up static files from the file system, as simple as that.

Classpath file serving

When you are delivering a complete jar file and all the resources are within the jar.

Caching Classpath file serving

When you are delivering a complete jar file and all the resources are within the jar, for each resource that is delivered, this will be placed in the cache for speedier delivery to the client.

This of course comes with the trade-off of memory usage versus speed.