Each middleware is instantiated with the one that follows him in the stack. • The last middleware is instantiated with the actual rack app. • Invoking call on this object will go through all the middlewares and the app.
instance of Journey::Router • we are inside the Journey engine, the rails router. • Its job is to ﬁnd the correct route deﬁned in conﬁg/routes.rb for the incoming request. • The router will choose the appropriate controller and action for this request, and place in the Rack env a hash containing them.
a controller from them. params[:controller] • If the controller is not found, Rails will return an empty response with the HTTP status code 404. • X-Cascade • dispatch(controller, params[:action], env)