1 | <?php declare(strict_types=1); |
||
14 | final class Middleware implements MiddlewareInterface |
||
15 | { |
||
16 | const HEADER = 'X-Middleware-Timer-Response'; |
||
17 | |||
18 | /** |
||
19 | * @var float[] |
||
20 | */ |
||
21 | private $times; |
||
22 | |||
23 | /** |
||
24 | * Return the processed $request via a fulfilled promise. |
||
25 | * When implementing cache or other feature that returns a response, do it with a rejected promise. |
||
26 | * If neither is possible, e.g. on some kind of failure, resolve the unaltered request. |
||
27 | * |
||
28 | * @param RequestInterface $request |
||
29 | * @param string $transactionId |
||
30 | * @param array $options |
||
31 | * @return CancellablePromiseInterface |
||
32 | * |
||
33 | * @Last() |
||
34 | */ |
||
35 | 1 | public function pre( |
|
44 | |||
45 | /** |
||
46 | * Return the processed $response via a promise. |
||
47 | * |
||
48 | * @param ResponseInterface $response |
||
49 | * @param string $transactionId |
||
50 | * @param array $options |
||
51 | * @return CancellablePromiseInterface |
||
52 | * |
||
53 | * @First() |
||
54 | */ |
||
55 | 1 | public function post( |
|
65 | |||
66 | /** |
||
67 | * @param Throwable $throwable |
||
68 | * @param string $transactionId |
||
69 | * @param array $options |
||
70 | * @return CancellablePromiseInterface |
||
71 | */ |
||
72 | public function error( |
||
79 | } |
||
80 |