So this is what I came up with...
In my app/index.js:
App = Spine.Controller.sub({
init: function() {
...
this.routes = new Routes({
el: $('#app')
});
Spine.Route.bind('before', this.proxy(this.beforeNavigate));
Spine.Route.setup({
history: true
});
},
beforeNavigate: function(path) {
if (this.routes.controllers[this.routes.routes[path.path]].prototype.loginRequired) {
console.log('require user is logged in.');
} else {
console.log('login not required.');
}
},
...
});
And in a controller I do:
MyController = Spine.Controller.sub({
...
loginRequired: true,
...
});
And Routes is just a Spine.Stack:
Routes = Spine.Stack.sub({
controllers: {
mycontroller: require('mycontroller')
},
routes: {
'/mycontroller': 'mycontroller'
}
});
This seems to work, but I'm open to suggestions.
Ideally I'd like to just be able to listen to the 'before' event in the context of a controller and not have to do all this lookup magic: