httpc
|
#include <tree.h>
Data Fields | |
char * | val |
a URI fsegment | |
struct node * | children |
All nodes, whose routes include this node's val in their fsegment. | |
struct node * | siblings |
All nodes, whose routes include this node's, parent's, val in their fsegment. | |
callback_t | callback |
The function that will be ran when a request comes. | |
If we imagine A single URI is a linked list of nodes, then every registered URI on the server is an N-ary tree of nodes. This N-ary tree is how I've implemented URIs in this library.
In the example below, some will have a child of silly, and silly will have a sibling of goofy. Both silly and goofy have their own children of uri (Note how every node will only point to one other node as "children", even though conceptually there can be many children via siblings). Assume every node has a callback, then the following endpoints will be served.
Legend:
--> : left's "children" points to right
|
v : top's "siblings" points to bottom