|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace League\Route; |
|
4
|
|
|
|
|
5
|
|
|
trait RouteCollectionMapTrait |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* Add a route to the map. |
|
9
|
|
|
* |
|
10
|
|
|
* @param array|string $method |
|
11
|
|
|
* @param string $path |
|
12
|
|
|
* @param string|callable $handler |
|
13
|
|
|
* |
|
14
|
|
|
* @return \League\Route\Route |
|
15
|
|
|
*/ |
|
16
|
|
|
abstract public function map($method, $path, $handler); |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Add a route that responds to GET HTTP method. |
|
20
|
|
|
* |
|
21
|
|
|
* @param string $path |
|
22
|
|
|
* @param string|callable $handler |
|
23
|
|
|
* |
|
24
|
|
|
* @return \League\Route\Route |
|
25
|
|
|
*/ |
|
26
|
12 |
|
public function get($path, $handler) |
|
27
|
|
|
{ |
|
28
|
12 |
|
return $this->map('GET', $path, $handler); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Add a route that responds to POST HTTP method. |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $path |
|
35
|
|
|
* @param string|callable $handler |
|
36
|
|
|
* |
|
37
|
|
|
* @return \League\Route\Route |
|
38
|
|
|
*/ |
|
39
|
15 |
|
public function post($path, $handler) |
|
40
|
|
|
{ |
|
41
|
15 |
|
return $this->map('POST', $path, $handler); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Add a route that responds to PUT HTTP method. |
|
46
|
|
|
* |
|
47
|
|
|
* @param string $path |
|
48
|
|
|
* @param string|callable $handler |
|
49
|
|
|
* |
|
50
|
|
|
* @return \League\Route\Route |
|
51
|
|
|
*/ |
|
52
|
9 |
|
public function put($path, $handler) |
|
53
|
|
|
{ |
|
54
|
9 |
|
return $this->map('PUT', $path, $handler); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Add a route that responds to PATCH HTTP method. |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $path |
|
61
|
|
|
* @param string|callable $handler |
|
62
|
|
|
* |
|
63
|
|
|
* @return \League\Route\Route |
|
64
|
|
|
*/ |
|
65
|
9 |
|
public function patch($path, $handler) |
|
66
|
|
|
{ |
|
67
|
9 |
|
return $this->map('PATCH', $path, $handler); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Add a route that responds to DELETE HTTP method. |
|
72
|
|
|
* |
|
73
|
|
|
* @param string $path |
|
74
|
|
|
* @param string|callable $handler |
|
75
|
|
|
* |
|
76
|
|
|
* @return \League\Route\Route |
|
77
|
|
|
*/ |
|
78
|
9 |
|
public function delete($path, $handler) |
|
79
|
|
|
{ |
|
80
|
9 |
|
return $this->map('DELETE', $path, $handler); |
|
81
|
3 |
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Add a route that responds to HEAD HTTP method. |
|
85
|
|
|
* |
|
86
|
|
|
* @param string $path |
|
87
|
|
|
* @param string|callable $handler |
|
88
|
|
|
* |
|
89
|
|
|
* @return \League\Route\Route |
|
90
|
|
|
*/ |
|
91
|
9 |
|
public function head($path, $handler) |
|
92
|
|
|
{ |
|
93
|
9 |
|
return $this->map('HEAD', $path, $handler); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Add a route that responds to OPTIONS HTTP method. |
|
98
|
|
|
* |
|
99
|
|
|
* @param string $path |
|
100
|
|
|
* @param string|callable $handler |
|
101
|
|
|
* |
|
102
|
|
|
* @return \League\Route\Route |
|
103
|
|
|
*/ |
|
104
|
9 |
|
public function options($path, $handler) |
|
105
|
|
|
{ |
|
106
|
9 |
|
return $this->map('OPTIONS', $path, $handler); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|