Modules (including handlers)
Modules are an easy way to extend routemaster
in a modular fashion without having to compile and deploy everything together.
In this way you may develop specific routes, features and handlers and package them into small binaries that can then be distributed easily.
The routemaster (server edition)
Routemaster now comes in a server
edition which is the lightest-weight version and contains no registered:
- options
- handlers
- routes (RESTful or otherwise)
Whilst this will still work as a web server, this will need to be extended by using modules.
The server version can be downloaded from the GitHub releases page. The jar that you are looking for is the one with the server
classifier (e.g. routemaster-2.1.0-server.jar
).
Setting up the server
Step 1: Download the jar file
Download the jar file.
Step 2: create a modules directory
In the same directory as the downloaded file (in fact it needs to be in the same directory from which you run the routemaster server) create a directory named modules
.
Step 3: Use the modules
In this directory - place any of the modules that you want to use.
Step 4: Start the server
Start the server with the command (for example)
java -jar routemaster-2.1.0-server.jar
The modules will then be loaded and registered for use
Configuring modules
By default, routemaster modules have in-built configuration options in the deployed module - they all must have a routemaster.properties
file in the root of the jar file - which is named the same as the module's jar name - for the example module, this would be named routemaster-module-example.properties
. This indicates to routemaster that this is a module to be loaded - all other jar files will be ignored.
That being said, you may over-ride the options that are the defaults by providing a separate file which is the name of the module appended with .properties
.For example:
routemaster-module-example-1.0.0.jar
Can have its properties over-ridden by providing a
routemaster-module-example.properties
file in the modules/
directory (i.e. the same directory that the module jar file resides).
Configuration priority
- The default
routemaster.properties
will be loaded first - this may be either in the directory that the routemaster server was started from, or within the root of the routemaster jar (if it exists). - The module properties are then checked next (i.e.
module_name.properties
) if they exist, then theroutemaster.properties
within the module jar file is not checked. - Finally, the
module_name.properties
within the module jar file is checked and loaded. NOTE that if the above properties file is found, then the properties file within the module jar is not checked.