Simple Routing

Simple routing, binds to a specific path (or wildcard path) and MUST extend the synapticloop.nanohttpd.router.Routable abstract class.

Instantiation

All classes that extend Routable will be automatically instantiated through the reading and parsing of the routemaster.properties file.

public Routable(String routeContext) {
	this.routeContext = routeContext;
}

Methods

This class has only one method:

  • public abstract Response serve(File rootDir, IHTTPSession httpSession);

serve

This method is where the response is generated and returned. There are static convenience methods in the snapticloop.nanohttpd.utils.HttpUtils to return various responses.

The file StaticFileListingServant.java provides an example of how to utilise the Routable serve method.