Adds a middleware class to the middleware stack. Any additional
 args and a block, if given, are saved and passed to the initializer
 of the middleware.

 @param [Class] middleware The middleware class
14424
def use(middleware, *args, &block)
      if middleware.is_a?(Builder)
        # Merge in the other builder's stack into our own
        stack.concat(middleware.stack)
      else
        stack << [middleware, args, block]
      end

      self
    end
671515
def use(middleware, *args, &block)
      if middleware.kind_of?(Builder)
        # Merge in the other builder's stack into our own
        self.stack.concat(middleware.stack)
      else
        self.stack << [middleware, args, block]
      end

      self
    end
474129
public function append(MiddlewareInterface $middleware): MiddlewarePipe
    {
        $stack = new MiddlewarePipe();

        /** @noinspection PhpParamsInspection */
        return $stack
            ->append($this)
            ->append($middleware);
    }
997701
def add_method_hooks
      eigen_class = @target.singleton_class

      if @options[:class_methods]
        return unless @target.is_a?(Module)

        orig_singleton_method_added = @target.method(:singleton_method_added)

        eigen_class.send :define_method, :singleton_method_added do |method|
          aspector_singleton_method_added(method)
          orig_singleton_method_added.call(method)
        end
      else
        if @target.is_a? Module
          orig_method_added = @target.method(:method_added)
        else
          orig_method_added = eigen_class.method(:method_added)
        end

        eigen_class.send :define_method, :method_added do |method|
          aspector_instance_method_added(method)
          orig_method_added.call(method)
        end
      end
    end
1197256
def use(middleware, *args, &block)
      return if faraday.builder.locked?
      faraday.builder.insert_before(Middleware::ParseJson, middleware, *args, &block)
    end
93087
def add(decorator)
      if decorators.include?(decorator)
        self.class.new(decorators)
      else
        self.class.new(decorators + [decorator])
      end
    end
1281071
public function addMiddleware($middleware, $priority = PriorityQueue::NORMAL)
    {
        $this->middlewares->insert($middleware, $priority);

        return $this;
    }
1269605
public function appendInit(callable $middleware, $name = null)
    {
        $this->add(self::INIT, $name, $middleware);
    }
1149966
def prepare_middleware(&context_definition)
      last_middleware = AllImportantMiddleware.new(&context_definition)
      Context.middlewares.inject(last_middleware) do |previous_middleware, middleware|
        middleware.new(previous_middleware)
      end.call(self)
    end
13405
def build
      @builder = Rack::Builder.new

      @middlewares.each do |middleware|
        if middleware[0] == :map
          @builder.map(middleware[1], &middleware[2])
        else
          @builder.use(*middleware[0], &middleware[1])
        end
      end

      @builder.run(@app)
    end
556850
def call(environment)
      app = adapter.new
      middlewares = @middlewares || []
      stack = Rack::Builder.new do
        middlewares.each do |middleware|
          klass, *args = middleware
          use klass, *args[0...-1].flatten, &args.last
        end
        run app
      end
      stack.call rack_env_defaults.merge(environment.update(env))
    end
152418
function (key) {
    // Assume the middleware is a function
    var middleware = key;

    // If the middleware is a string
    if (typeof middleware === 'string') {
      // Look it up and assert it was found
      middleware = MIDDLEWARES[key];
      assert(middleware, 'value-mapper middleware "' + key + '" could not be found."');
    }

    // Add the middleware to our stack
    this.middlewares.push(middleware);
  }
965296
protected function registerMiddleware($middleware)
    {
        /** @var Kernel $kernel */
        $kernel = $this->getContainer()->get(KernelInterface::class);
        $kernel->prependMiddleware($middleware);
    }
991222
def middleware(self, *args, **kwargs):
        

        def register_middleware(_middleware):
            future_middleware = FutureMiddleware(_middleware, args, kwargs)
            self.middlewares.append(future_middleware)
            return _middleware

        # Detect which way this was called, @middleware or @middleware('AT')
        if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
            middleware = args[0]
            args = []
            return register_middleware(middleware)
        else:
            if kwargs.get("bp_group") and callable(args[0]):
                middleware = args[0]
                args = args[1:]
                kwargs.pop("bp_group")
                return register_middleware(middleware)
            else:
                return register_middleware
862278
def rescue_middleware
      @rescue_middleware ||= GraphQL::Schema::RescueMiddleware.new.tap { |m| middleware.insert(0, m) }
    end
670555
def add_service(key, *args)

      raise ArgumentError.new(
        '#add_service: at least two arguments please'
      ) if args.empty?

      key = key.to_s
      path, klass, opts = args

      key = "s_#{key}" unless SERVICE_PREFIX.match(key)

      aa = [ self, opts ].compact

      service = if klass

        require(path)

        @services[key] = Ruote.constantize(klass).new(*aa)

      elsif path.is_a?(Class)

        @services[key] = path.new(*aa)

      else

        @services[key] = path
      end

      (class << self; self; end).class_eval(
        %{ def #{key[2..-1]}; @services['#{key}']; end })
          #
          # This 'two-liner' will add an instance method to Context for this
          # service.
          #
          # If the service key is 's_dishwasher', then the service will be
          # available via Context#dishwasher.
          #
          # I.e. dishwasher = engine.context.dishwasher

      service
    end
352167
def use(klass, *args, &block)
      request_handler   = "#{klass.name}::RequestHandler".safe_constantize
      response_handler  = "#{klass.name}::ResponseHandler".safe_constantize
      exception_handler = "#{klass.name}::ExceptionHandler".safe_constantize

      request_handlers   << request_handler.new(*args, &block) if request_handler
      response_handlers  << response_handler.new(*args, &block) if response_handler
      exception_handlers << exception_handler.new(*args, &block) if exception_handler
    end