Last active
August 29, 2015 14:18
-
-
Save ChitaGideon/356e063f1e413d6424ad to your computer and use it in GitHub Desktop.
find all route path in krakenjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.on 'middleware:after:router',(eventargs)-> | |
routes = [] | |
app._router.stack.forEach (route)-> | |
getPath = (route)-> | |
route.path ||route.route?.path || route.regexp.toString().match(/[\/\w]+/g)[1..-4].join("") | |
recurPath = (route,head,arr)-> | |
routeStr = getPath(route) | |
if route.handle?.stack | |
route.handle.stack.forEach (subRoute)-> | |
recurPath(subRoute,head+routeStr,arr) | |
else if route.route?.stack | |
route.route.stack.forEach (subRoute)-> | |
recurPath(subRoute,head+routeStr,arr) | |
else | |
o = {} | |
o[route.method] = head+routeStr | |
arr.push o | |
if(route.name == "router") | |
recurPath route,"",routes | |
debug "routes ",routes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment