151 unmodified lines
Expand all
// uri.relative
// uri.source
// uri.params
// headers [[foo, bar]]
return (this.findRouteFor(request) || this.defaultRoute).callback()
return (this.findRouteFor(request) || this.defaultRoute).callback(Express.passToRoute)
},
findRouteFor : function(request) {
for (var i = 0, len = this.routes.length; i < len; ++i)
routeMatches : function(route, request) {
if (route.method != request.method.toLowerCase()) return false
switch (route.path.constructor) {
case String: return route.path == request.uri.path
case RegExp: return request.uri.path.match(route.path)
case RegExp:
if (captures = request.uri.path.match(route.path))
return Express.passToRoute = captures
}
},
routeFunctionFor : function(method) {
get ('/users', function(){
return 'List of users'
})
get (/foo(bar)?/, function(captures){
Express.dump(captures)
return 'test'
})
post ('/users', function(){
return 'Posted data'
})
Express.start()
No newline at end of file
No newline at end of file