
Domain routing in Waaseyaa: replacing a giant dispatcher with small routers
Ahnii! Waaseyaa had a controller dispatcher that grew past 1,000 lines. Every new feature meant more conditionals in the same file. This post covers how that dispatcher was replaced with domain-specific routers, each implementing a two-method interface that keeps routing logic scoped and testable. What a Dispatcher Does graph TD A[HTTP Request] --> B[Router] B -->|matches URL to route| C[Dispatcher] C -->|picks controller, injects context| D[Controller] D --> E[Response] The router matches a URL to a route definition. The dispatcher takes that match and figures out which controller to instantiate, which method to call, and how to pass in the request context. In most frameworks, you never think about it because the framework handles it for you. The problem starts when the dispatcher becomes the place where "which code to run" turns into a long chain of conditionals. Why a Monolithic Dispatcher Breaks Down A single dispatcher that handles every request type accumulates conditionals fast.
Continue reading on Dev.to
Opens in a new tab


