Closed MartB closed 11 months ago
Interesting.
I'm not sure what version you tested on and/or if you have some extra code layer (since you have a entry.get()
) but
the following example seems to work fine on the 2.0
branch.
The problem you probably faced is that you need to take the length into account when print out the entry.
R3Node *n = r3_tree_create(10);
r3_tree_insert_path(n, "/api/{username:\\w+}/{action:\\w+}", NULL);
r3_tree_compile(n, NULL);
match_entry *entry = match_entry_create("/api/sesame/open");
R3Node *matched = r3_tree_match_entry(n, entry);
for (int i = 0; i < entry->vars.tokens.size; i++) {
// Only print given length
printf("[%d] is: %.*s\n", i, entry->vars.tokens.entries[i].len, entry->vars.tokens.entries[i].base);
}
match_entry_free(entry);
r3_tree_free(n);
[0] is: sesame
[1] is: open
Do still have this problem or do you have any objections if we close this issue?
Will revisit once i get time to work on that old project again, but we can surely close this issue now :+1:
Is it possible to create something like:
/api/username:\\w+/:action:\\w+
and have it properly match username and action, so i can use these as params in my code?Im currently reading the data back from the tokenlist and the stuff it returns is a mess.
this is what i would expect from a dumb regex parser but not from a path dispatch solution.
generated by the following code: