Routemaster
a router for the truly excellent nanohttpd
Install / Use
/learn @synapticloop/RoutemasterREADME
<a name="#documentr_top"></a>
This project requires JVM version of at least 1.7
<a name="documentr_heading_0"></a>
routemaster <sup><sup>top</sup></sup>
lightweight web server with RESTful routing
<a name="documentr_heading_1"></a>
Table of Contents <sup><sup>top</sup></sup>
RouteMaster
Handy routing controller for the truly excellent nanohttpd tiny, easily embeddable HTTP Java server.
See https://synapticloop.github.io/routemaster/ for full documentation

<a name="documentr_heading_2"></a>
Templating with Templar templating language <sup><sup>top</sup></sup>
Yes, you can now do some server side includes, using the synapticloop templar templating language!
A quick example is:
{import src/main/html/templar-handler.snippet}
<a name="documentr_heading_3"></a>
Module support <sup><sup>top</sup></sup>
To make it quicker and easier to get started with routemaster, we added in module functionality so that it can be easily extended.
Instructions:
Download the routemaster-<version>-server.jar from the github releases directory (which contains all of the dependencies that are required), download modules that you require and place them in the modules directory from where you launched the routemaster server.
These will be automatically registered and ready to go.
For an example module with everything you need to build and deploy, see https://github.com/synapticloop/routemaster-module-example.
Some of the available modules
Thumbnailer routemaster-module-thumbnailer automatically generate thumbnails of images on the fly.
Templar Handler routemaster-module-templar-handler add templar templating language handling to the routemaster server.
Static file lister routemaster-module-static-file-lister add in static file listing and navigation.
<a name="documentr_heading_6"></a>
Options <sup><sup>top</sup></sup>
Following the NanoHTTPD, you may pass in the following options
- h
--host The host to bind to - default 127.0.0.1
-p
--port The port to bind to - default 5474
-d
--dir The directory that the html files reside in
<a name="documentr_heading_7"></a>
As an aside <sup><sup>top</sup></sup>
The name RouteMaster pays homage to the original London buses (see the wikipedia entry) which would take you wherever you would like to go.
The favicon is also related, showing a depiction of the back top window of a routemaster bus.
Building the Package
*NIX/Mac OS X
From the root of the project, simply run
./gradlew build
Windows
./gradlew.bat build
This will compile and assemble the artefacts into the build/libs/ directory.
Note that this may also run tests (if applicable see the Testing notes)
Running the Tests
*NIX/Mac OS X
From the root of the project, simply run
gradle --info test
if you do not have gradle installed, try:
gradlew --info test
Windows
From the root of the project, simply run
gradle --info test
if you do not have gradle installed, try:
./gradlew.bat --info test
The --info switch will also output logging for the tests
Artefact Publishing - Github
This project publishes artefacts to GitHub
Note that the latest version can be found https://github.com/synapticloop/routemaster/releases
As such, this is not a repository, but a location to download files from.
Artefact Publishing - Bintray
This project publishes artefacts to bintray
Note that the latest version can be found https://bintray.com/synapticloop/maven/routemaster/view
maven setup
this comes from the jcenter bintray, to set up your repository:
<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd' xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bintray</activeProfile>
</activeProfiles>
</settings>
gradle setup
Repository
repositories {
maven {
url "http://jcenter.bintray.com"
}
}
or just
repositories {
jcenter()
}
Dependencies - Gradle
dependencies {
runtime(group: 'synapticloop', name: 'routemaster', version: '2.3.0', ext: 'jar')
compile(group: 'synapticloop', name: 'routemaster', version: '2.3.0', ext: 'jar')
}
or, more simply for versions of gradle greater than 2.1
dependencies {
runtime 'synapticloop:routemaster:2.3.0'
compile 'synapticloop:routemaster:2.3.0'
}
Dependencies - Maven
<dependency>
<groupId>synapticloop</groupId>
<artifactId>routemaster</artifactId>
<version>2.3.0</version>
<type>jar</type>
</dependency>
Dependencies - Downloads
You will also need to download the following dependencies:
cobertura dependencies
net.sourceforge.cobertura:cobertura:2.0.3: (It may be available on one of: bintray mvn central)
compile dependencies
synapticloop:templar:1.4.2: (It may be available on one of: bintray mvn central)org.nanohttpd:nanohttpd:2.3.1: (It may be available on one of: bintray mvn central)
runtime dependencies
synapticloop:templar:1.4.2: (It may be available on one of: bintray mvn central)org.nanohttpd:nanohttpd:2.3.1: (It may be available on one of: bintray mvn central)
server dependencies
org.nanohttpd:nanohttpd:2.3.1: (It may be available on one of: bintray mvn central)
testCompile dependencies
junit:junit:4.11: (It may be available on one of: bintray mvn central)org.mockito:mockito-all:1.10.19: (It may be available on one of: bintray mvn central)synapticloop:templar:1.4.2: (It may be available on one of: bintray mvn central)
NOTE: You may need to download any dependencies of the above dependencies in turn (i.e. the transitive dependencies)
License
The MIT License (MIT)
Copyright (c) 2017 synapticloop
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
