Skip to content

Commit

Permalink
Use ^ to override baseUrl for direct middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsm committed Nov 10, 2015
1 parent ed0580b commit e8ada5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/service/farcaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Farcaster.build = function(serviceAnnouncement) {
},

run: function(options) {
debug('run local version of remote service "%s"', this.name)
debug('[%s] run local version of remote service', this.name)
if (isNaN(+options.port)) {
this.router.startServer(options.port)
}
Expand Down
16 changes: 12 additions & 4 deletions lib/web/framework/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,21 @@ ExpressAdapter.prototype.serveAsset = function(asset, router, service) {
* @return {ExpressAdapter} The instance of this adpater.
*/
ExpressAdapter.prototype.useMiddleware = function(url, middleware, service) {
debug('[%s] use middleware directly at url "%s"', service.name, url)
if (!Array.isArray(url)) {
url = [url]
}

// make sure we mount middleware under the correct base url
url.forEach(function(link, idx) {
if ('^' !== link[0]) {
url[idx] = path.join(service.baseUrl, link)
}
})

debug('[%s] use middleware directly at url "%s"', service.name, url)

var app = this.getApp()
var m = express()
m.use(url, middleware(app))
app.use(service.baseUrl, m)
app.use(url, middleware(app))
}

/**
Expand Down

0 comments on commit e8ada5d

Please sign in to comment.