diff --git a/include/r3.h b/include/r3.h index 1fdf51f..0b47663 100644 --- a/include/r3.h +++ b/include/r3.h @@ -129,4 +129,12 @@ match_entry * match_entry_create(char * path, int path_len); void match_entry_free(match_entry * entry); + + + +route_info * route_info_create(char * path); + +route_info * route_info_createl(char * path, int path_len); + + #endif /* !NODE_H */ diff --git a/src/node.c b/src/node.c index a4f6412..6d67a9b 100644 --- a/src/node.c +++ b/src/node.c @@ -194,6 +194,23 @@ void r3_tree_compile_patterns(node * n) { } } +route_info * route_info_create(char * path) { + return route_info_createl(path, strlen(path)); +} + +route_info * route_info_createl(char * path, int path_len) { + route_info * info = malloc(sizeof(route_info)); + info->path = path; + info->path_len = path_len; + info->request_methods = 0; // can be (GET || POST) + + info->host = NULL; // required host name + info->host_len = 0; + + info->remote_addr_pattern = NULL; + info->remote_addr_pattern_len = 0; + return info; +} match_entry * match_entry_create(char * path, int path_len) { match_entry * entry = malloc(sizeof(match_entry)); diff --git a/tests/check_tree.c b/tests/check_tree.c index 806110c..055d4e2 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -257,9 +257,25 @@ START_TEST (test_str_array) } END_TEST + +START_TEST(test_insert_route) +{ + match_entry * entry = match_entry_create(); + + + node * tree = r3_tree_create(2); + + + route_info *info = route_info_create("/blog/post", strlen("/blog/post") ); + + // r3_tree_insert_route(n, "/foo/bar/baz", NULL); + +} +END_TEST + START_TEST(benchmark_str) { - match_entry * entry = calloc( sizeof(entry) , 1 ); + match_entry * entry = match_entry_create(); node * n = r3_tree_create(1); @@ -627,6 +643,7 @@ START_TEST(benchmark_str) } END_TEST + Suite* r3_suite (void) { Suite *suite = suite_create("blah");