Re:Node.js in Flame Graphs
by nostrademons on Wednesday November 19, 2014 @06:19PM
(#8633354)
The easiest way is to not conflate middleware handling with routing. Your routing infrastructure should take a dict mapping URL patterns to callables, and returns a callable (which uses this DFA-based approach to dispatch). Your middleware should be a callable that wraps another callable. If you want to apply middleware to just one path, wrap it before you register it with the routing table. If you want to apply middleware to all (or a subset of) paths, wrap the returned routing table, and optionally stick that in some other routing table.
[ Parent
| on HN ]
There are no comments on this comment yet.