public function handshake(Request $request, Response $response): array
    {
        try {
            $path = $request->getUri()->getPath();
            list($className,) = $this->getHandler($path);
        } catch (\Throwable $e) {
            /* @var ErrorHandler $errorHandler */
            // $errorHandler = \bean(ErrorHandler::class);
            // $response = $errorHandler->handle($e);
            if ($e instanceof WsRouteException) {
                return [
                    HandlerInterface::HANDSHAKE_FAIL,
                    $response->withStatus(404)->withAddedHeader('Failure-Reason', 'Route not found')
                ];
            }

            // other error
            throw $e;
        }

        /** @var HandlerInterface $handler */
        $handler = \bean($className);

        if (!\method_exists($handler, 'checkHandshake')) {
            return [
                HandlerInterface::HANDSHAKE_OK,
                $response->withAddedHeader('swoft-ws-handshake', 'auto')
            ];
        }

        return $handler->checkHandshake($request, $response);
    }