This project requires JVM version of at least 1.7
routemaster-module-templar-handler top
Templar templating language module support for routemaster
Table of Contents top
- routemaster-module-templar-handler
- Table of Contents
- Creating a new module
- Deploying modules
- Running the server
- Building the Package
- Running the Tests
This is an example module that offers additional, modular support for synapticloop routemaster.
Routemaster modules can be automatically loaded from the modules
directory that
Creating a new module top
Setup top
Download the latest version of the source code, and unzip it into your project working directory.
The structure of the folder is as follows:
build.gradle
(the build.gradle file)gradle
gradlew
gradlew.bat
settings.gradle
(the settings file for gradle)src
(the source files directory)
Configuration top
This is the main build file and contains everything to build the module. It can be executed by typing the following:
gradle build
If you are on windows:
gradle.bat build
The file contents are:
plugins {
id 'java'
id 'eclipse'
id "maven"
id "maven-publish"
id "com.github.ben-manes.versions" version "0.13.0"
id 'net.saliman.cobertura' version '2.2.6'
id 'co.riiid.gradle' version '0.4.2'
id "synapticloop.copyrightr" version "1.1.2"
id "synapticloop.documentr" version "2.9.0"
}
version = '1.0.0'
//
// ensure that you change the following values
//
group = 'synapticloop'
archivesBaseName = 'routemaster-module-templar-handler'
description = """Templar templating language module support for routemaster"""
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
runtime 'synapticloop:routemaster:2.1.0'
compile 'synapticloop:routemaster:2.1.0'
}
github {
owner = group
repo = archivesBaseName
if(System.getenv('GITHUB_TOKEN')) {
token = System.getenv('GITHUB_TOKEN')
}
tagName = version
name = version
assets = [
'build/libs/' + archivesBaseName + '-' + version + '.jar',
]
}
You will also want to change the settings.gradle
file:
rootProject.name = 'routemaster-module-templar-handler'
so that the rootProject.name
value matches your project name.
Code top
All the code resides in the src/main/java
directory, with resources in the src/main/resources
directory.
You MUST have a routemaster.properties
file deployed with every module jar or it will not be activated.
The routemaster.properties
file has the same standard layout as the default properties file, and may map options, handlers and routes (both RESTful and not).
Some things to note:
All properties defined in the module jar file will over-write any existing properties that are set.
The rouetmaster.properties
file deployed with this module is as follows:
option.indexfiles=index.html.templar,index.html,index.htm
# Now for some handlers - this is for the templar handle (bound to *.templar)
handler.templar=synapticloop.nanohttpd.handler.TemplarHandler
Deploying modules top
Step 1 top
To deploy the built module, ensure that you have downloaded the latest routemaster server from github routemaster releases (the jar file is the one that has the server
classifier - e.g. routemaster-2.0.0-server.jar
).
Note: The server version has NO functionality built in - i.e. no routes are defined - instead all functionality must come from the modules. It will still operate successfully, however all the modules must map the routes.
Step 2 top
Create a modules
directory which is in the same directory that the downloaded file is (your directory listing should look something like the following:
/routemaster-2.0.0-server.jar
/modules/
Step 3 top
Place the module (or multiple modules) into the modules
directory so that it will look something like the following:
/routemaster-2.0.0-server.jar
/modules/
/routemaster-module-example-1.0.0.jar
Running the server top
now run the server:
java -jar routemaster-2.0.0-server.jar
For the example above, the only routes that are mapped are:
/module/example/
/module/example/*
If you open http://localhost:5474/module/example/
you will see something along the lines of:
Hello from the example module, this page was brought to you by the letter 'H'
Building the Package top
*NIX/Mac OS X top
From the root of the project, simply run
./gradlew build
Windows top
./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 top
*NIX/Mac OS X top
From the root of the project, simply run
gradle --info test
if you do not have gradle installed, try:
gradlew --info test
Windows top
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
Dependencies - Gradle top
dependencies {
runtime(group: 'synapticloop', name: 'routemaster-module-templar-handler', version: '1.0.0', ext: 'jar')
compile(group: 'synapticloop', name: 'routemaster-module-templar-handler', version: '1.0.0', ext: 'jar')
}
or, more simply for versions of gradle greater than 2.1
dependencies {
runtime 'synapticloop:routemaster-module-templar-handler:1.0.0'
compile 'synapticloop:routemaster-module-templar-handler:1.0.0'
}
Dependencies - Maven top
<dependency>
<groupId>synapticloop</groupId>
<artifactId>routemaster-module-templar-handler</artifactId>
<version>1.0.0</version>
<type>jar</type>
</dependency>
Dependencies - Downloads top
You will also need to download the following dependencies:
net.sourceforge.cobertura:cobertura:2.0.3
: (It may be available on one of: bintray mvn central)
synapticloop:routemaster:2.1.0
: (It may be available on one of: bintray mvn central)
synapticloop:routemaster:2.1.0
: (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)
--
This README.md file was hand-crafted with care utilising synapticloop
templar
->
documentr
--