kennethkoontz / mold

Web framework using node.js
http://kennethkoontz.github.com/mold/
1 stars 0 forks source link

make mold routing dynamic #7

Open kennethkoontz opened 12 years ago

kennethkoontz commented 12 years ago

Right now, mold routing doesn't parse the url for parameters. It takes a static string and maps that directly to a single action. It would be useful to parse the url and extract the parameters, passing it into an action.

So we could do something like.

in routes.js:

'/foo/:id': 'foo'

in actions.js:

foo: function() {
    this.params['id'] // returns value of 'id' in params object.
}
kennethkoontz commented 12 years ago

I'd like to change the implementation for routing, rather then using an object; I'd like to use an array. There are constraints with using the object approach and looking up by key, if the key is regex.

kennethkoontz commented 12 years ago

var routes = module.exports = [ ['/^regex', 'blah'], ['another/regex', 'foobar'], ['another/:id', 'blaggle'] ]