mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
Added param() with default value
This commit is contained in:
parent
fac66a9082
commit
0736ed6318
|
|
@ -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'
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user