Merge pull request #678 from braydonf/feature/configurable-routes
Added ability to configure HTTP route prefixes.
This commit is contained in:
commit
7d68b0cc82
|
@ -6,6 +6,16 @@ var fs = require('fs');
|
|||
|
||||
var InsightUI = function(options) {
|
||||
BaseService.call(this, options);
|
||||
if (typeof options.apiPrefix !== 'undefined') {
|
||||
this.apiPrefix = options.apiPrefix;
|
||||
} else {
|
||||
this.apiPrefix = 'insight-api';
|
||||
}
|
||||
if (typeof options.routePrefix !== 'undefined') {
|
||||
this.routePrefix = options.routePrefix;
|
||||
} else {
|
||||
this.routePrefix = 'insight';
|
||||
}
|
||||
};
|
||||
|
||||
InsightUI.dependencies = ['insight-api'];
|
||||
|
@ -18,7 +28,7 @@ InsightUI.prototype.start = function(callback) {
|
|||
};
|
||||
|
||||
InsightUI.prototype.getRoutePrefix = function() {
|
||||
return 'insight';
|
||||
return this.routePrefix;
|
||||
};
|
||||
|
||||
InsightUI.prototype.setupRoutes = function(app, express) {
|
||||
|
@ -38,9 +48,13 @@ InsightUI.prototype.setupRoutes = function(app, express) {
|
|||
|
||||
InsightUI.prototype.filterIndexHTML = function(data) {
|
||||
var transformed = data
|
||||
.replace(/<base href=\"\/\"/, '<base href="/insight/"')
|
||||
.replace(/apiPrefix = '\/api'/, "apiPrefix = '/insight-api'");
|
||||
.replace(/apiPrefix = '\/api'/, "apiPrefix = '/" + this.apiPrefix + "'");
|
||||
|
||||
if (this.routePrefix) {
|
||||
transformed = transformed.replace(/<base href=\"\/\"/, '<base href="/' + this.routePrefix + '/"');
|
||||
}
|
||||
|
||||
return transformed;
|
||||
};
|
||||
|
||||
module.exports = InsightUI;
|
||||
module.exports = InsightUI;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="insight navbar-brand" href="/insight">insight</a>
|
||||
<a class="insight navbar-brand" href=".">insight</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" collapse="$root.isCollapsed">
|
||||
<ul class="nav navbar-nav">
|
||||
|
|
Loading…
Reference in New Issue