public function pipe($path, $middleware = null)
    {
        if (null === $middleware && is_callable($path)) {
            $middleware = $path;
            $path       = '/';
        }

        // Ensure we have a valid handler
        if (! is_callable($middleware)) {
            throw new InvalidArgumentException('Middleware must be callable');
        }

        $this->pipeline->enqueue(new Route(
            $this->normalizePipePath($path),
            $middleware
        ));

        // @todo Trigger event here with route details?
        return $this;
    }
public function pipe($path, $middleware = null)
    {
        if (null === $middleware && is_callable($path)) {
            $middleware = $path;
            $path       = '/';
        }

        // Ensure we have a valid handler
        if (! is_callable($middleware)) {
            throw new InvalidArgumentException('Middleware must be callable');
        }

        $this->pipeline->enqueue(new Route(
            $this->normalizePipePath($path),
            $middleware
        ));

        // @todo Trigger event here with route details?
        return $this;
    }
public function pipe ( $ path , $ middleware = null ) { if ( null === $ middleware && is_callable ( $ path ) ) { $ middleware = $ path ; $ path = '/' ; } // Ensure we have a valid handler if ( ! is_callable ( $ middleware ) ) { throw new InvalidArgumentException ( 'Middleware must be callable' ) ; } $ this -> pipeline -> enqueue ( new Route ( $ this -> normalizePipePath ( $ path ) , $ middleware ) ) ; // @todo Trigger event here with route details? return $ this ; }
Attach middleware to the pipeline.

Each middleware can be associated with a particular path; if that
path is matched when that middleware is invoked, it will be processed;
otherwise it is skipped.

No path means it should be executed every request cycle.

A handler CAN implement MiddlewareInterface, but MUST be callable.

Handlers with arity >= 4 or those implementing ErrorMiddlewareInterface
are considered error handlers, and will be executed when a handler calls
$next with an error or raises an exception.

@see MiddlewareInterface
@see ErrorMiddlewareInterface
@see Next
@param string|callable|object $path Either a URI path prefix, or middleware.
@param null|callable|object $middleware Middleware
@return self
Attach middleware to the pipeline .