Repository navigation
Expand file tree
/
Copy pathServer.php
More file actions
46 lines (39 loc) · 1.39 KB
/
Copy pathServer.php
File metadata and controls
46 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\GrpcServer;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Dispatcher\HttpDispatcher;
use Hyperf\ExceptionHandler\ExceptionHandlerDispatcher;
use Hyperf\GrpcServer\Exception\Handler\GrpcExceptionHandler;
use Hyperf\HttpServer\Server as HttpServer;
use Psr\Container\ContainerInterface;
class Server extends HttpServer
{
public function __construct(
ContainerInterface $container,
HttpDispatcher $dispatcher,
ExceptionHandlerDispatcher $exceptionHandlerDispatcher,
ResponseEmitter $responseEmitter
) {
parent::__construct($container, $dispatcher, $exceptionHandlerDispatcher, $responseEmitter);
}
public function initCoreMiddleware(string $serverName): void
{
$this->serverName = $serverName;
$this->coreMiddleware = new CoreMiddleware($this->container, $serverName);
$config = $this->container->get(ConfigInterface::class);
$this->middlewares = $config->get('middlewares.' . $serverName, []);
$this->exceptionHandlers = $config->get('exceptions.handler.' . $serverName, [
GrpcExceptionHandler::class,
]);
$this->initOption();
}
}