DynamicRoutes.Dispatcher (DynamicRoutes v0.1.0)

Copy Markdown View Source

The plug the internal catch-all route points at.

Its job is to undo the rewrite before the controller sees it. Matching a database-backed URL means temporarily replacing conn.path_info with an internal one so that Phoenix's compiled router has something to match; if that replacement were still in place inside the controller, every canonical URL it built would name a path no client ever requested.

So this sits between the route and the controller: the pipeline has already run, the path goes back to what the client actually sent, and the controller is invoked with a conn that looks exactly as it would have if the route had been declared in the first place.