RoutesDetecting::exception()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Server detecting of custom routes
4
 * User: moyo
5
 * Date: 2018/4/20
6
 * Time: 3:29 PM
7
 */
8
9
namespace Carno\HRPC\Handlers;
10
11
use Carno\Chain\Layered;
12
use Carno\Coroutine\Context;
13
use Carno\HRPC\Client\Contracts\Defined;
14
use Carno\HRPC\Client\Handlers\RoutesMarking;
15
use Carno\HTTP\Standard\Request;
16
use Throwable;
17
18
class RoutesDetecting implements Layered
19
{
20
    public function inbound($request, Context $ctx)
21
    {
22
        /**
23
         * @var Request $http
24
         */
25
26
        $http = $ctx->get(ServerWrapper::REQUESTING);
27
28
        if ($http->hasHeader(Defined::X_ROUTE_TAGS)) {
29
            $ctx->set(RoutesMarking::FLAG, $http->getHeader(Defined::X_ROUTE_TAGS));
30
        }
31
32
        return $request;
33
    }
34
35
    public function outbound($response, Context $ctx)
36
    {
37
        return $response;
38
    }
39
40
    public function exception(Throwable $e, Context $ctx)
41
    {
42
        throw $e;
43
    }
44
}
45