mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-03 04:08:01 +08:00
Deleted useless code.
This commit is contained in:
parent
4585a09565
commit
5220b2227d
@ -22,7 +22,6 @@ class ConfigProvider
|
||||
{
|
||||
return [
|
||||
'dependencies' => [
|
||||
Server::class => ServerFactory::class,
|
||||
RequestInterface::class => Request::class,
|
||||
ServerRequestInterface::class => Request::class,
|
||||
ResponseInterface::class => Response::class,
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Hyperf\HttpServer;
|
||||
|
||||
use FastRoute\Dispatcher;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Contract\MiddlewareInitializerInterface;
|
||||
use Hyperf\Contract\OnRequestInterface;
|
||||
@ -20,6 +21,7 @@ use Hyperf\ExceptionHandler\ExceptionHandlerDispatcher;
|
||||
use Hyperf\HttpMessage\Server\Request as Psr7Request;
|
||||
use Hyperf\HttpMessage\Server\Response as Psr7Response;
|
||||
use Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler;
|
||||
use Hyperf\HttpServer\Router\DispatcherFactory;
|
||||
use Hyperf\Utils\Context;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
@ -36,11 +38,6 @@ class Server implements OnRequestInterface, MiddlewareInitializerInterface
|
||||
*/
|
||||
protected $middlewares;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $coreHandler;
|
||||
|
||||
/**
|
||||
* @var MiddlewareInterface
|
||||
*/
|
||||
@ -66,16 +63,10 @@ class Server implements OnRequestInterface, MiddlewareInitializerInterface
|
||||
*/
|
||||
protected $serverName;
|
||||
|
||||
public function __construct(
|
||||
string $serverName,
|
||||
string $coreHandler,
|
||||
ContainerInterface $container,
|
||||
$dispatcher
|
||||
) {
|
||||
$this->serverName = $serverName;
|
||||
$this->coreHandler = $coreHandler;
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->dispatcher = $container->get(HttpDispatcher::class);
|
||||
}
|
||||
|
||||
public function initCoreMiddleware(string $serverName): void
|
||||
@ -123,6 +114,16 @@ class Server implements OnRequestInterface, MiddlewareInitializerInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function createDispatcher(string $serverName): Dispatcher
|
||||
{
|
||||
$factory = $this->container->get(DispatcherFactory::class);
|
||||
return $factory->getDispatcher($serverName);
|
||||
}
|
||||
|
||||
protected function parse(): array
|
||||
{
|
||||
}
|
||||
|
||||
protected function getDefaultExceptionHandler(): array
|
||||
{
|
||||
return [
|
||||
@ -132,8 +133,7 @@ class Server implements OnRequestInterface, MiddlewareInitializerInterface
|
||||
|
||||
protected function createCoreMiddleware(): MiddlewareInterface
|
||||
{
|
||||
$coreHandler = $this->coreHandler;
|
||||
return new $coreHandler($this->container, $this->serverName);
|
||||
return new CoreMiddleware($this->container, $this->serverName);
|
||||
}
|
||||
|
||||
protected function initRequestAndResponse(SwooleRequest $request, SwooleResponse $response): array
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://doc.hyperf.io
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Hyperf\HttpServer;
|
||||
|
||||
use Hyperf\Dispatcher\HttpDispatcher;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class ServerFactory
|
||||
{
|
||||
protected $coreMiddleware = CoreMiddleware::class;
|
||||
|
||||
public function __invoke(ContainerInterface $container): Server
|
||||
{
|
||||
return new Server('http', $this->coreMiddleware, $container, $container->get(HttpDispatcher::class));
|
||||
}
|
||||
}
|
@ -23,7 +23,6 @@ class ConfigProvider
|
||||
return [
|
||||
'dependencies' => [
|
||||
TcpServer::class => TcpServerFactory::class,
|
||||
HttpServer::class => HttpServerFactory::class,
|
||||
DataFormatter::class => DataFormatterFactory::class,
|
||||
],
|
||||
'commands' => [
|
||||
|
@ -18,6 +18,7 @@ use Hyperf\HttpServer\Server;
|
||||
use Hyperf\JsonRpc\Exception\Handler\HttpExceptionHandler;
|
||||
use Hyperf\Rpc\Protocol;
|
||||
use Hyperf\Rpc\ProtocolManager;
|
||||
use Hyperf\RpcServer\RequestDispatcher;
|
||||
use Hyperf\Utils\Context;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
@ -44,14 +45,10 @@ class HttpServer extends Server
|
||||
*/
|
||||
protected $responseBuilder;
|
||||
|
||||
public function __construct(
|
||||
string $serverName,
|
||||
string $coreHandler,
|
||||
ContainerInterface $container,
|
||||
$dispatcher,
|
||||
ProtocolManager $protocolManager
|
||||
) {
|
||||
parent::__construct($serverName, $coreHandler, $container, $dispatcher);
|
||||
public function __construct(ContainerInterface $container, ProtocolManager $protocolManager)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->dispatcher = $container->get(RequestDispatcher::class);
|
||||
$this->protocol = new Protocol($container, $protocolManager, 'jsonrpc-http');
|
||||
$this->packer = $this->protocol->getPacker();
|
||||
$this->responseBuilder = make(ResponseBuilder::class, [
|
||||
@ -69,8 +66,7 @@ class HttpServer extends Server
|
||||
|
||||
protected function createCoreMiddleware(): MiddlewareInterface
|
||||
{
|
||||
$coreHandler = $this->coreHandler;
|
||||
return new $coreHandler($this->container, $this->protocol, $this->serverName);
|
||||
return new HttpCoreMiddleware($this->container, $this->protocol, $this->serverName);
|
||||
}
|
||||
|
||||
protected function initRequestAndResponse(SwooleRequest $request, SwooleResponse $response): array
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://doc.hyperf.io
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace Hyperf\JsonRpc;
|
||||
|
||||
use Hyperf\Rpc\ProtocolManager;
|
||||
use Hyperf\RpcServer\RequestDispatcher;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class HttpServerFactory
|
||||
{
|
||||
protected $coreMiddleware = HttpCoreMiddleware::class;
|
||||
|
||||
public function __invoke(ContainerInterface $container): HttpServer
|
||||
{
|
||||
$dispatcher = $container->get(RequestDispatcher::class);
|
||||
$protocolManager = $container->get(ProtocolManager::class);
|
||||
return new HttpServer('jsonrpc-http', $this->coreMiddleware, $container, $dispatcher, $protocolManager);
|
||||
}
|
||||
}
|
@ -13,13 +13,11 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Testing;
|
||||
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
use Hyperf\Dispatcher\HttpDispatcher;
|
||||
use Hyperf\HttpMessage\Server\Request as Psr7Request;
|
||||
use Hyperf\HttpMessage\Server\Response as Psr7Response;
|
||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
use Hyperf\HttpMessage\Upload\UploadedFile;
|
||||
use Hyperf\HttpMessage\Uri\Uri;
|
||||
use Hyperf\HttpServer\CoreMiddleware;
|
||||
use Hyperf\HttpServer\MiddlewareManager;
|
||||
use Hyperf\HttpServer\Server;
|
||||
use Hyperf\Utils\Arr;
|
||||
@ -49,7 +47,7 @@ class Client extends Server
|
||||
|
||||
public function __construct(ContainerInterface $container, PackerInterface $packer = null, $server = 'http')
|
||||
{
|
||||
parent::__construct('http', CoreMiddleware::class, $container, $container->get(HttpDispatcher::class));
|
||||
parent::__construct($container);
|
||||
$this->packer = $packer ?? new JsonPacker();
|
||||
|
||||
$this->initCoreMiddleware($server);
|
||||
|
Loading…
Reference in New Issue
Block a user