public function doHandler(ServerRequestInterface $request, array $routeInfo)
    {
        /**
         * @var int $status
         * @var string $path
         * @var array  $info
         */
        list($status, $path, $info) = $routeInfo;

        // not founded route
        if ($status === HandlerMapping::NOT_FOUND) {
            throw new RouteNotFoundException('Route not found for ' . $path);
        }

        // method not allowed
        if ($status === HandlerMapping::METHOD_NOT_ALLOWED) {
            throw new MethodNotAllowedException(sprintf(
                "Method '%s' not allowed for access %s, Allow: %s",
                $request->getMethod(),
                $path,
                \implode(',', $routeInfo[2])
            ));
        }

        // handler info
        list($handler, $matches) = $this->createHandler($path, $info);

        if (\is_array($handler)) {
            $handler = $this->defaultHandler($handler);
        }

        // execute handler
        $params   = $this->bindParams($request, $handler, $matches);
        $response = PhpHelper::call($handler, $params);

        // response
        if (!$response instanceof Response) {
            /* @var Response $newResponse*/
            $newResponse = RequestContext::getResponse();

            // if is Payload
            if ($response instanceof Payload) {
                $response = $newResponse
                    ->withStatus($response->getStatus())
                    ->withAttribute(AttributeEnum::RESPONSE_ATTRIBUTE , $response->data);
            } else {
                $response = $newResponse->withAttribute(AttributeEnum::RESPONSE_ATTRIBUTE , $response);
            }
        }

        return $response;
    }
public function doHandler(ServerRequestInterface $request, array $routeInfo)
    {
        /**
         * @var int $status
         * @var string $path
         * @var array  $info
         */
        list($status, $path, $info) = $routeInfo;

        // not founded route
        if ($status === HandlerMapping::NOT_FOUND) {
            throw new RouteNotFoundException('Route not found for ' . $path);
        }

        // method not allowed
        if ($status === HandlerMapping::METHOD_NOT_ALLOWED) {
            throw new MethodNotAllowedException(sprintf(
                "Method '%s' not allowed for access %s, Allow: %s",
                $request->getMethod(),
                $path,
                \implode(',', $routeInfo[2])
            ));
        }

        // handler info
        list($handler, $matches) = $this->createHandler($path, $info);

        if (\is_array($handler)) {
            $handler = $this->defaultHandler($handler);
        }

        // execute handler
        $params   = $this->bindParams($request, $handler, $matches);
        $response = PhpHelper::call($handler, $params);

        // response
        if (!$response instanceof Response) {
            /* @var Response $newResponse*/
            $newResponse = RequestContext::getResponse();

            // if is Payload
            if ($response instanceof Payload) {
                $response = $newResponse
                    ->withStatus($response->getStatus())
                    ->withAttribute(AttributeEnum::RESPONSE_ATTRIBUTE , $response->data);
            } else {
                $response = $newResponse->withAttribute(AttributeEnum::RESPONSE_ATTRIBUTE , $response);
            }
        }

        return $response;
    }
public function doHandler ( ServerRequestInterface $ request , array $ routeInfo ) { /**
         * @var int $status
         * @var string $path
         * @var array  $info
         */ list ( $ status , $ path , $ info ) = $ routeInfo ; // not founded route if ( $ status === HandlerMapping :: NOT_FOUND ) { throw new RouteNotFoundException ( 'Route not found for ' . $ path ) ; } // method not allowed if ( $ status === HandlerMapping :: METHOD_NOT_ALLOWED ) { throw new MethodNotAllowedException ( sprintf ( "Method '%s' not allowed for access %s, Allow: %s" , $ request -> getMethod ( ) , $ path , \ implode ( ',' , $ routeInfo [ 2 ] ) ) ) ; } // handler info list ( $ handler , $ matches ) = $ this -> createHandler ( $ path , $ info ) ; if ( \ is_array ( $ handler ) ) { $ handler = $ this -> defaultHandler ( $ handler ) ; } // execute handler $ params = $ this -> bindParams ( $ request , $ handler , $ matches ) ; $ response = PhpHelper :: call ( $ handler , $ params ) ; // response if ( ! $ response instanceof Response ) { /* @var Response $newResponse*/ $ newResponse = RequestContext :: getResponse ( ) ; // if is Payload if ( $ response instanceof Payload ) { $ response = $ newResponse -> withStatus ( $ response -> getStatus ( ) ) -> withAttribute ( AttributeEnum :: RESPONSE_ATTRIBUTE , $ response -> data ) ; } else { $ response = $ newResponse -> withAttribute ( AttributeEnum :: RESPONSE_ATTRIBUTE , $ response ) ; } } return $ response ; }
Execute handler with controller and action

@param ServerRequestInterface $request request object
@param array $routeInfo handler info
@return Response
@throws \Swoft\Exception\InvalidArgumentException
@throws \InvalidArgumentException
@throws \Swoft\Http\Server\Exception\MethodNotAllowedException
@throws \Swoft\Http\Server\Exception\RouteNotFoundException
@throws \ReflectionException
Execute handler with controller and action