Skip to content

Instantly share code, notes, and snippets.

@eduardobc88
Created March 23, 2017 17:38
Show Gist options
  • Save eduardobc88/2ab7f53a386535a87e227d98bce5d002 to your computer and use it in GitHub Desktop.
Save eduardobc88/2ab7f53a386535a87e227d98bce5d002 to your computer and use it in GitHub Desktop.
Express remove route
function express_remove_route(router_path,callback) {
express_stack = router.stack;
console.log("================= express_remove_route ==================");
express_stack.forEach(function(route_layer){
if( !route_layer ) return;
if( route_layer.route.path.indexOf(router_path) >= 1 ) {
//console.log(router_path,route_layer.route.path.indexOf(router_path)); // log layer
idx = express_stack.indexOf(route_layer);
//console.log("IDX",idx); // id to remove layer
express_stack.splice(idx, 1);
}
});
console.log("================= express_remove_route ==================");
callback();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment