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

Router: map_table() #33

Open
edsiper opened this issue Nov 19, 2014 · 0 comments
Open

Router: map_table() #33

edsiper opened this issue Nov 19, 2014 · 0 comments
Assignees
Milestone

Comments

@edsiper
Copy link
Member

edsiper commented Nov 19, 2014

string matching is a pain, using regex is not a solution for the URL matching context. Take the following scenario as an example:

router->map("/myapp/users/foo", cb_users_foo);
router->map("/myapp/users/bar", cb_users_bar);
router->map("/myapp/users", cb_users_all);

if the URL matches the last pattern /myapp/users, we are wasting resources doing many strings comparissons for a same prefix pattern, map_table() should implement something like this:

router->map_table("/myapp/users",
                  NULL, cb_users_all,  DUDA_METHOD_ANY,
                  "foo",   cb_users_foo, DUDA_METHOD_GET,
                  "bar",   cb_users_bar, DUDA_METHOD_POST | DUDA_METHOD_PUT );

on this way we provide two extra features:

  • Reduce the number of strings comparisons required setting sub-patterns over a root prefix.
  • Provide an extra flag to determinate the expected methods to match the callback.
@edsiper edsiper self-assigned this Nov 19, 2014
@edsiper edsiper added this to the DST-2 milestone Nov 19, 2014
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

1 participant