def replace(index, middleware, *args, &block)
      if index.is_a?(Integer)
        delete(index)
        insert(index, middleware, *args, &block)
      else
        insert_before(index, middleware, *args, &block)
        delete(index)
      end
    end
def replace(index, middleware, *args, &block)
      if index.is_a?(Integer)
        delete(index)
        insert(index, middleware, *args, &block)
      else
        insert_before(index, middleware, *args, &block)
        delete(index)
      end
    end
Replaces the given middleware object or index with the new
 middleware.