intiialize route_info struct
This commit is contained in:
parent
516ddddda3
commit
639dd1e0e6
3 changed files with 43 additions and 1 deletions
|
@ -129,4 +129,12 @@ match_entry * match_entry_create(char * path, int path_len);
|
||||||
|
|
||||||
void match_entry_free(match_entry * entry);
|
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 */
|
#endif /* !NODE_H */
|
||||||
|
|
17
src/node.c
17
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 * match_entry_create(char * path, int path_len) {
|
||||||
match_entry * entry = malloc(sizeof(match_entry));
|
match_entry * entry = malloc(sizeof(match_entry));
|
||||||
|
|
|
@ -257,9 +257,25 @@ START_TEST (test_str_array)
|
||||||
}
|
}
|
||||||
END_TEST
|
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)
|
START_TEST(benchmark_str)
|
||||||
{
|
{
|
||||||
match_entry * entry = calloc( sizeof(entry) , 1 );
|
match_entry * entry = match_entry_create();
|
||||||
node * n = r3_tree_create(1);
|
node * n = r3_tree_create(1);
|
||||||
|
|
||||||
|
|
||||||
|
@ -627,6 +643,7 @@ START_TEST(benchmark_str)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
Suite* r3_suite (void) {
|
Suite* r3_suite (void) {
|
||||||
Suite *suite = suite_create("blah");
|
Suite *suite = suite_create("blah");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue