       defp match(var!(conn), unquote(route.verb), unquote(route.path_segments),
                  unquote(route.host_segments)) do
         unquote(Route.maybe_merge(:private, route.private))
-
-        var!(conn) =
-          update_in(var!(conn).params, &Map.merge(&1, unquote(parts)))
-          |> Plug.Conn.put_private(:phoenix_pipelines, unquote(route.pipe_through))
-          |> Plug.Conn.put_private(:phoenix_route, fn conn ->
-              opts = unquote(route.controller).init(unquote(route.action))
-              unquote(route.controller).call(conn, opts)
-             end)
-
+        var!(conn) = dispatch(var!(conn), unquote(route.controller), unquote(route.action),
+                              unquote(parts), unquote(route.pipe_through))
         unquote(route.pipe_segments)
       end
     end

        raise NoRouteError, conn: conn, router: __MODULE__
      end

      unquote(channels)
    end
  end

  end

  defp add_resources(path, controller, options, do: context) do
    scope =
      if context do
        quote do
          scope resource.member, do: unquote(context)
        end
      end

    quote do
      resource = Resource.build(unquote(path), unquote(controller), unquote(options))

