1 | <?php |
||
11 | class Route extends EventEmitter |
||
12 | { |
||
13 | use EventTrait; |
||
14 | |||
15 | /** |
||
16 | * Regexp ready route |
||
17 | * @var String |
||
18 | */ |
||
19 | public $parsedRoute; |
||
20 | |||
21 | /** |
||
22 | * Route method type |
||
23 | * @var String |
||
24 | */ |
||
25 | public $method; |
||
26 | |||
27 | /** |
||
28 | * Route action |
||
29 | * @var Callable |
||
30 | */ |
||
31 | public $action; |
||
32 | |||
33 | /** |
||
34 | * Route uri |
||
35 | * @var String |
||
36 | */ |
||
37 | private $uri; |
||
38 | |||
39 | /** |
||
40 | * Route filters |
||
41 | * @var array |
||
42 | */ |
||
43 | private $filters = []; |
||
44 | |||
45 | /** |
||
46 | * @param String $method |
||
47 | * @param String $uri |
||
48 | * @param Callable $action |
||
49 | */ |
||
50 | public function __construct ($method, $uri, $action) |
||
56 | |||
57 | /** |
||
58 | * Create a new filter for current route |
||
59 | * |
||
60 | * @param String|array $param parameter to filter |
||
61 | * @param String $filter regexp to execute |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public function where($param, $filter) |
||
75 | |||
76 | /** |
||
77 | * Parse route uri |
||
78 | * |
||
79 | * @return void |
||
80 | */ |
||
81 | public function parse() |
||
92 | |||
93 | /** |
||
94 | * Check if uri is parsed |
||
95 | * |
||
96 | * @return boolean |
||
97 | */ |
||
98 | public function isParsed() |
||
102 | |||
103 | /** |
||
104 | * Check if path match route uri |
||
105 | * @param String $path |
||
106 | * @param String $method |
||
107 | * @return bool |
||
108 | */ |
||
109 | public function match($path, $method) |
||
118 | |||
119 | /** |
||
120 | * Parse route arguments |
||
121 | * @param String $path |
||
122 | * @return array |
||
123 | */ |
||
124 | public function getArgs($path) |
||
140 | |||
141 | /** |
||
142 | * Run the current route |
||
143 | * |
||
144 | * @param Callable $next |
||
145 | * @param \React\Http\Request $request |
||
146 | * @param \React\Restify\Response $response |
||
147 | * |
||
148 | * @return Void |
||
149 | */ |
||
150 | public function run(Callable $next, Request $request, Response $response) |
||
166 | } |
||
167 |