diff --git a/README.md b/README.md index 39b891251..a9faab6dd 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,4 @@ Read about the [features of LoopBack](https://github.com/strongloop/loopback/wik A brief guide for [contributing to LoopBack projects](https://github.com/strongloop/loopback/wiki/How-To-Contribute). [![githalytics.com alpha](https://cruel-carlota.pagodabox.com/8caf6b5cce4be4d13c01ea9aafc9f407 "githalytics.com")](http://githalytics.com/strongloop/loopback) + diff --git a/lib/application.js b/lib/application.js index d1c2b17e3..f2d321866 100644 --- a/lib/application.js +++ b/lib/application.js @@ -249,7 +249,7 @@ app.docs = function (options) { swagger(remotes, options); } -/*! +/** * Get a handler of the specified type from the handler cache. */ @@ -264,6 +264,14 @@ app.handler = function (type) { return handler; } +/** + * Clears handler of the specified type from the handler cache. + */ + +app.clearHandlerCache = function (type) { + this._handlers[type] = undefined; +} + /** * An object to store dataSource instances. */ diff --git a/test/app.test.js b/test/app.test.js index 701d22fe7..60ceadd76 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -85,6 +85,14 @@ describe('app', function() { }); }); + describe('app.clearHandlerCache(type)', function() { + it('clears handler of given type from cache', function() { + var restHandler = app.handler('rest'); + app.clearHandlerCache('rest'); + expect(restHandler).to.not.equal(app.handler('rest')); + }); + }); + describe('app.boot([options])', function () { beforeEach(function () { app.boot({