Skip to content

Router: map_table() #33

@edsiper

Description

@edsiper

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions