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

(Feature Request) Named routes #401

Closed
jneen opened this issue Aug 17, 2010 · 4 comments
Closed

(Feature Request) Named routes #401

jneen opened this issue Aug 17, 2010 · 4 comments

Comments

@jneen
Copy link

jneen commented Aug 17, 2010

The idea here is to have a Single Source of Truth for my routes. So for example:

app.get('myRoute', '/foo/:bar', function() { ... });
app.routes.myRoute.path(2) // => '/foo/2'
app.routes.myRoute.path({bar: 'baz'}) // => '/foo/baz'
app.routes.myRoute.url({bar: 37}) // => 'http://example.com/foo/37'

Alternatively, app.verb could return a route object, which could be made available through exports. I'd also be happy to work on this feature.

@tj
Copy link
Member

tj commented Aug 17, 2010

sorry I dont think I want this. however you could easily roll your own, view the resource example, I think that could be tweeked to do what you want here.

@jneen
Copy link
Author

jneen commented Aug 18, 2010

Fair enough. The resource example doesn't quite cut it, unfortunately, since urls like '/user/3' still had to be hardcoded. I suppose I could put routes on my models, but I'd really like to hook in to the parsing of url wildcards, as in rkh/sinatra-advanced-routes. I'll try my hand at rolling my own for the time being, but I should be able to come up with something a little more general.

Actually, just exposing a method (this is in Connect, I guess) to resolve a path given a route template and keys would be sufficient.

@jneen
Copy link
Author

jneen commented Aug 21, 2010

So I've rolled my own in a general fashion - I realized the functionality I wanted is independent of Connect's route resolution. It's up here. Thanks for your patience!

@tj
Copy link
Member

tj commented Aug 21, 2010

cool man :D

This issue was closed.
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