We are passing so many arguments to each function pointer yet we can just pass struct Router that contains everything we need.
Simplifies to:
struct Dispatcher {
HandlerFunc (*match)(struct Router* router, Request* req);
void (*add_route)(struct Router* router, const char* pattern, HandlerFunc handler);
void (*mount)(struct Router* parent, const char* prefix, struct Router* child);
void (*free)(struct Dispatcher* self);
};
Once again, eliminating opaque pointers while still staying flexible enough.
We are passing so many arguments to each function pointer yet we can just pass struct Router that contains everything we need.
Simplifies to:
Once again, eliminating opaque pointers while still staying flexible enough.