Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named predefined params #2127

Closed
rodrigok opened this issue May 21, 2014 · 1 comment
Closed

Named predefined params #2127

rodrigok opened this issue May 21, 2014 · 1 comment

Comments

@rodrigok
Copy link

Using this code from doc

app.param (name, regexp) ->
    if Object.prototype.toString.call(regexp) == '[object RegExp]'
        return (req, res, next, val) ->
            if captures = regexp.exec(String(val))
                req.params[name] = captures[0]
                next()
            else
                next('route')

I can use named params with regex match, but I can't use this param more than 1 time and generic names make the url a little messy.

I can't do this

app.get '/purchase/:objectId/:objectId', (req, res, next) ->

There are some way to name this params like below?

app.get '/purchase/:(objectId)place/:(objectId)user', (req, res, next) ->
    console.log req.params.place, req.params.user
@dougwilson
Copy link
Contributor

The capturing and the route syntax is handled by https://github.com/component/path-to-regexp

Please file an issue there. When it gets implemented there, it'll come into express.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants