A router is that part of the web application that determines where the incoming request should go. It figures it out by examining the request URL and then invoking a pre-defined function (or a handler) for that path. Internally, it stores the mapping between the URL patterns and the corresponding handlers.
In Ruby on Rails, the router sends the incoming request to an action method on a controller. In the next lesson, we'll build our own controllers and modify our router (that we'll build today) to dispatch the request to the controller#action
code.
Let's see how we can build our simple router.