1 | <?php namespace Nimo\Traits; |
||
8 | trait MiddlewareTrait |
||
9 | { |
||
10 | use AttachToRequestTrait; |
||
11 | |||
12 | /** |
||
13 | * append $middleware after this one, return the new $middlewareStack |
||
14 | * |
||
15 | * @param $middleware |
||
16 | * @return MiddlewarePipe |
||
17 | */ |
||
18 | public function append($middleware): MiddlewarePipe |
||
26 | |||
27 | /** |
||
28 | * prepend $middleware before this one, return the new $middlewareStack |
||
29 | * |
||
30 | * @param $middleware |
||
31 | * @return MiddlewarePipe |
||
32 | */ |
||
33 | public function prepend($middleware): MiddlewarePipe |
||
41 | |||
42 | /** |
||
43 | * wrap this middleware with $conditionCallback (skip this when the callback return falsy value) |
||
44 | * |
||
45 | * @param callable $conditionCallback ($req, $res, $next) |
||
46 | * @return ConditionMiddleware |
||
47 | */ |
||
48 | public function when(callable $conditionCallback): MiddlewareInterface |
||
52 | |||
53 | public function catch(callable $catcher, string $catchClass = \Throwable::class): MiddlewareInterface |
||
57 | } |
||
58 |