Changed routing example
This commit is contained in:
parent
40e0e1c2a0
commit
839001afec
1 changed files with 6 additions and 6 deletions
|
@ -17,7 +17,7 @@ void test1(void) {
|
|||
int route_data = 3;
|
||||
|
||||
// insert the R3Route path into the router tree
|
||||
r3_tree_insert_routel(n, METHOD_GET | METHOD_POST, "/blog/{post}/asdi/{id}", sizeof("/blog/{post}/asdi/{id}") - 1, &route_data );
|
||||
r3_tree_insert_routel(n, METHOD_GET | METHOD_POST, "/blog", sizeof("/blog") - 1, &route_data );
|
||||
r3_tree_insert_routel(n, METHOD_GET | METHOD_POST, "/blog/{post}/asf/{id}", sizeof("/blog/{post}/asf/{id}") - 1, &route_data );
|
||||
r3_tree_insert_routel(n, METHOD_GET | METHOD_POST, "/blog/{post}/asd/{id:[0-9]+}/qwe", sizeof("/blog/{post}/asd/{id:[0-9]+}/qwe") - 1, &route_data );
|
||||
|
||||
|
@ -36,17 +36,17 @@ void test1(void) {
|
|||
match_entry * entry;
|
||||
R3Route *matched_route;
|
||||
// for (int k = 0; k < 3000000; k++) {
|
||||
entry = match_entry_create("/blog/nnn/asdi/kkkk");
|
||||
entry = match_entry_create("/blog");
|
||||
if (entry != NULL) {
|
||||
entry->request_method = METHOD_GET;
|
||||
matched_route = r3_tree_match_route(n, entry);
|
||||
if (matched_route != NULL) {
|
||||
// printf("Routed data is: %d\n", *(int*)matched_route->data); // get the data from matched route
|
||||
for (int i = 0; i < entry->vars->len; i++) {
|
||||
// entry->vars->slugs[i];
|
||||
// entry->vars->tokens[i];
|
||||
printf("Slug name is: %s\n",entry->vars->slugs[i]);
|
||||
printf("Slug value is: %s\n",entry->vars->tokens[i]);
|
||||
entry->vars->slugs[i];
|
||||
entry->vars->tokens[i];
|
||||
// printf("Slug name is: %s\n",entry->vars->slugs[i]);
|
||||
// printf("Slug value is: %s\n",entry->vars->tokens[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue