src/Router/HandlerAdapter.php
public function doHandler(ServerRequestInterface $request, array $handler): Response
    {
        // the function params of service
        $data = $request->getAttribute(PackerMiddleware::ATTRIBUTE_DATA);
        $params = $data['params'] ?? [];

        list($serviceClass, $method) = $handler;
        $service = App::getBean($serviceClass);

        // execute handler with params
        $response = PhpHelper::call([$service, $method], $params);
        $response = ResponseHelper::formatData($response);

        // response
        if (! $response instanceof Response) {
            $response = (new Response())->withAttribute(self::ATTRIBUTE, $response);
        }

        return $response;
    }
public function doHandler(ServerRequestInterface $request, array $handler): Response
    {
        // the function params of service
        $data = $request->getAttribute(PackerMiddleware::ATTRIBUTE_DATA);
        $params = $data['params'] ?? [];

        list($serviceClass, $method) = $handler;
        $service = App::getBean($serviceClass);

        // execute handler with params
        $response = PhpHelper::call([$service, $method], $params);
        $response = ResponseHelper::formatData($response);

        // response
        if (! $response instanceof Response) {
            $response = (new Response())->withAttribute(self::ATTRIBUTE, $response);
        }

        return $response;
    }
public function doHandler ( ServerRequestInterface $ request , array $ handler ) : Response { // the function params of service $ data = $ request -> getAttribute ( PackerMiddleware :: ATTRIBUTE_DATA ) ; $ params = $ data [ 'params' ] ?? [ ] ; list ( $ serviceClass , $ method ) = $ handler ; $ service = App :: getBean ( $ serviceClass ) ; // execute handler with params $ response = PhpHelper :: call ( [ $ service , $ method ] , $ params ) ; $ response = ResponseHelper :: formatData ( $ response ) ; // response if ( ! $ response instanceof Response ) { $ response = ( new Response ( ) ) -> withAttribute ( self :: ATTRIBUTE , $ response ) ; } return $ response ; }
Execute service handler

@param \Psr\Http\Message\ServerRequestInterface $request
@param array                                    $handler
@return Response
Execute service handler