I want to dynamically during runtime of sailsjs add/remove routes. what is the way?
I found a function to add route:
sails.router.bind(path, target);
and it will work but when I ant to unbind it, it does not work.
sails.router.unbind(???);
I want to dynamically during runtime of sailsjs add/remove routes. what is the way?
I found a function to add route:
sails.router.bind(path, target);
and it will work but when I ant to unbind it, it does not work.
sails.router.unbind(???);
its a route object includes method and path
Source code as below
Router.prototype.unbind = function(route) {
var sails = this.sails;
// Inform attached servers that route should be unbound
sails.emit('router:unbind', route);
// Remove route in internal router
var newRoutes = [];
_.each(this._privateRouter.routes[route.method], function(expressRoute) {
if (expressRoute.path != route.path) {
newRoutes.push(expressRoute);
}
});
this._privateRouter.routes[route.method] = newRoutes;
};