Added param() with default value

This commit is contained in:
visionmedia 2009-06-26 14:23:36 -07:00
parent fac66a9082
commit 0736ed6318

View File

@ -129,6 +129,10 @@
this.response.headers[name]
},
param : function(key, defaultValue) {
return this.request.uri.params[key] || defaultValue
},
/**
* Return the contents of a function body.
*
@ -190,11 +194,11 @@
})()
get ('/users', function(){
return 'List of users'
if (user = param('user')) return 'User: ' + user
else return 'List of users'
})
get (/foo(bar)?/, function(){
dump(captures)
return 'test'
})