| Total Complexity | 4 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 18 | class RoutesMarking implements Layered |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * flag in ctx |
||
| 22 | */ |
||
| 23 | public const FLAG = 'routes.marked'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param Request $request |
||
| 27 | * @param Context $ctx |
||
| 28 | * @return Request |
||
| 29 | */ |
||
| 30 | public function inbound($request, Context $ctx) |
||
| 31 | { |
||
| 32 | $tags = $ctx->get(self::FLAG) ?? $request->getTags(); |
||
| 33 | if ($tags !== Tags::DEFAULT) { |
||
| 34 | $request->opsExtra('h-headers', static function (&$headers) use ($request, $tags) { |
||
| 35 | $request->setTags(...$tags); |
||
| 36 | $headers[Defined::X_ROUTE_TAGS] = implode(',', $tags); |
||
| 37 | }); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $request; |
||
| 41 | } |
||
| 42 | |||
| 43 | public function outbound($response, Context $ctx) |
||
| 44 | { |
||
| 45 | return $response; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function exception(Throwable $e, Context $ctx) |
||
| 51 | } |
||
| 52 | } |
||
| 53 |