Add a New Service to the Knox Gateway
The Knox Gateway supports a declarative way for you to “plug in” a new service into the gateway simply and easily by using a few files.
Overview
Services and service additions in the Knox Gateway are defined as extensions to existing Knox Gateway functionality that enable you to extend the gateway’s capabilities. You use these services to convert information contained in the topology file to runtime descriptors.
The Knox Gateway supports a declarative way for you to “plug in” a new service into the gateway simply and easily by using the following two files:
service.xml
- file that contains the routes (paths) that the service will provide and the rewrite rules to bind these paths.rewrite.xml
– file that contains the rewrite rules for the service.
Directory Structure
The Knox Gateway consists of a directory structure that you should become familiar with before attempting to add a new service to the gateway.
Services
Service name
Version
service.xml
rewrite.xml
Services
WebHDFS
2.4.0
service.xml
rewrite.xml
<GATEWAY_HOME>/data/services/webhdfs/0.0.1/service.xml
<service role="WEBHDFS" name="webhdfs" version="0.0.1">
<routes>
<route path="/webhdfs/**"/>
</routes>
</service>
<GATEWAY_HOME>/data/services/webhdfs/0.0.1/rewrite.xml
<rules>
<rule dir="IN" name="WEBHDFS/webhdfs/inbound" pattern="*://*:*/**/webhdfs/{path=**}?{**}">
<rewrite template="{$serviceUrl[WEBHDFS]}/{path=**}?{**}"/>
</rule>
</rules>