From 839001afec4d766a3514fbadc192b47537297619 Mon Sep 17 00:00:00 2001 From: karantin2020 Date: Tue, 8 Mar 2016 19:24:21 +0500 Subject: [PATCH] Changed routing example --- examples/routing.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/routing.c b/examples/routing.c index 48644ad..6d83c01 100644 --- a/examples/routing.c +++ b/examples/routing.c @@ -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]); } } }