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

Already on GitHub? Sign in to your account

addRoute implemented #7

4 commits merged into from Dec 21, 2010


None yet
2 participants

maritz commented Nov 30, 2010

This implements Ni.addRoute(source, destination[, method]);

I've included some documentation in the README.md.

Some of my usages:
Ni.addRoute('/', '/News/index');
Ni.addRoute(/^/register/i, '/User/register');
Ni.addRoute(/^/logout/i, '/User/logout');
Ni.addRoute(/^/login/i, '/User/login');

We could theoretically add some stuff by default.
Ni.addRoute(//([^/]+)/?$/, '$1/index');

This would "save" us some lines where we check if an action is in the path and else call index. This has some esoteric drawbacks, not sure if you'd want it.

Another one:
Ni.addRoute('/', '/home/index');

This one would save us 17 lines in the router and I think is definitely something we should do.

Feel free to give me feedback about my version of Ni.addRoute() or merge it if you think it's good the way it is.

In its current state it also kinda solves my method problems. However it's not perfect for that as well (as my other solution).


maritz commented Nov 30, 2010

Arg, somehow my editor fucked up the indentation of my additions in lib/ni.js. Feel free to correct it as you see fit.


chetan51 commented Dec 1, 2010

Excellent, I'll merge your commits this weekend. Thanks!


maritz commented Dec 20, 2010

bump :-D


chetan51 commented Dec 21, 2010

Merged, sorry about the delay :D

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment