update sample code
This commit is contained in:
parent
65052fbe5c
commit
12de194a28
1 changed files with 12 additions and 0 deletions
12
README.md
12
README.md
|
@ -57,6 +57,18 @@ r3_tree_insert_pathl(n ,"/post/{id}", strlen("/post/{id}") , &route_data );
|
||||||
|
|
||||||
r3_tree_insert_pathl(n, "/user/{id:\\d+}", strlen("/user/{id:\\d+}"), &route_data );
|
r3_tree_insert_pathl(n, "/user/{id:\\d+}", strlen("/user/{id:\\d+}"), &route_data );
|
||||||
|
|
||||||
|
|
||||||
|
// if you want to cache error, you may call the extended path function for insertion
|
||||||
|
int data = 10;
|
||||||
|
char *errstr = NULL;
|
||||||
|
node *ret = r3_tree_insert_pathl_ex(n, "/foo/{name:\\d{5}", strlen("/foo/{name:\\d{5}"), NULL, &data, &errstr);
|
||||||
|
if (ret == NULL) {
|
||||||
|
// failed insertion
|
||||||
|
printf("error: %s\n", errstr);
|
||||||
|
free(errstr); // errstr is created from `asprintf`, so you have to free it manually.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// let's compile the tree!
|
// let's compile the tree!
|
||||||
char *errstr = NULL;
|
char *errstr = NULL;
|
||||||
int err = r3_tree_compile(n, &errstr);
|
int err = r3_tree_compile(n, &errstr);
|
||||||
|
|
Loading…
Reference in a new issue