Problems with the current API
- It doesn't compose
a. Reitit middleware and coercion don't work
b. Default handlers are hard to use
c. Doesn't work with macro-based routing (not sure if we can solve this one?)
- The API sucks
route-spec, route-params, and route-dispatcher can be combined into one fn that just returns all the data
Solutions
(2) is easy; just update API and call sites.
(1) is harder. Maybe we can dynamically create a handler fn for each dispatcher. This is effectively decreasing the scope of Bread itself.
This vastly simplifies the ::route lifecycle phase, since we know at dispatch time which route we picked. All we do is inject the data already on hand from the matched route. The Reitit Router implementation, for example, could just grab ::r/match (injected by reitit.ring) from the request itself.
Problems with the current API
a. Reitit middleware and coercion don't work
b. Default handlers are hard to use
c. Doesn't work with macro-based routing (not sure if we can solve this one?)
route-spec,route-params, androute-dispatchercan be combined into one fn that just returns all the dataSolutions
(2) is easy; just update API and call sites.
(1) is harder. Maybe we can dynamically create a handler fn for each dispatcher. This is effectively decreasing the scope of Bread itself.
This vastly simplifies the
::routelifecycle phase, since we know at dispatch time which route we picked. All we do is inject the data already on hand from the matched route. The ReititRouterimplementation, for example, could just grab::r/match(injected by reitit.ring) from the request itself.