1 | <?php declare(strict_types=1); |
||
14 | final class Middleware implements MiddlewareInterface |
||
15 | { |
||
16 | /** |
||
17 | * Return the processed $request via a fulfilled promise. |
||
18 | * When implementing cache or other feature that returns a response, do it with a rejected promise. |
||
19 | * If neither is possible, e.g. on some kind of failure, resolve the unaltered request. |
||
20 | * |
||
21 | * @param RequestInterface $request |
||
22 | * @param array $options |
||
23 | * @return CancellablePromiseInterface |
||
24 | */ |
||
25 | public function pre(RequestInterface $request, array $options = []): CancellablePromiseInterface |
||
30 | |||
31 | /** |
||
32 | * Return the processed $response via a promise. |
||
33 | * |
||
34 | * @param ResponseInterface $response |
||
35 | * @param array $options |
||
36 | * @return CancellablePromiseInterface |
||
37 | */ |
||
38 | public function post(ResponseInterface $response, array $options = []): CancellablePromiseInterface |
||
43 | |||
44 | /** |
||
45 | * Deal with possible errors that occurred during request/response events. |
||
46 | * |
||
47 | * @param Throwable $throwable |
||
48 | * @param array $options |
||
49 | * @return CancellablePromiseInterface |
||
50 | */ |
||
51 | public function error(Throwable $throwable, array $options = []): CancellablePromiseInterface |
||
56 | |||
57 | /** |
||
58 | * Priority ranging from 0 to 1000. Where 1000 will be executed first on `pre` and 0 last on `pre`. |
||
59 | * For `post` the order is reversed. |
||
60 | * |
||
61 | * @return int |
||
62 | */ |
||
63 | public function priority(): int |
||
68 | } |
||
69 |