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