middleware for subtags
Closed this issue · 4 comments
benaghaeipour commented
Hi Cris,
Middleware doesn't appear to run on subroutes
auth = (ctx,next,page) ->
console.log('middleware')
return next() if @loggedIn
page.redirect('/login')
routes = [
{route:"/",tag:"home"}
{route:"/login/",tag:"login"}
{route:"/settings/",tag:"settings", routes:[
{route:"/",tag:"subpage"}
{route:"/hello",use:auth}
{route:"/hello",tag:"subpage"}
]}
]
So going to /settings/hello I don't see middleware in the console.
crisward commented
Taking a look into this now.
crisward commented
The middleware wasn't concatenating it's path parts, so was only working on root routes. I've amended this, but it's still not mounting the tag when I call next. I'll hopefully have a fix for that soon.
crisward commented
That's fixed, I swapped the order of two lines of code, and for reasons I'm not entirely sure I understand all the tests suddenly passed. It's the tdd equivalent of restarting your computer.
crisward commented
I'm pushing the latest version 1.2.3 to npm now.