@@ -133,7 +133,7 @@ public function getRouteProperties($route, Request $request)
133133 $ methods = isset ($ route ['methods ' ]) ? $ route ['methods ' ] : (array ) $ request ->getMethod ();
134134 $ action = (isset ($ route [1 ]) && is_array ($ route [1 ])) ? $ route [1 ] : $ route ;
135135
136- if ($ request -> getMethod () === 'GET ' && ! in_array ('HEAD ' , $ methods )) {
136+ if (in_array ( 'GET ' , $ methods ) && ! in_array ('HEAD ' , $ methods )) {
137137 $ methods [] = 'HEAD ' ;
138138 }
139139
@@ -269,6 +269,8 @@ public function getIterableRoutes($version = null)
269269 }
270270
271271 foreach ($ routes as $ route ) {
272+ $ route ['methods ' ] = $ this ->setRouteMethods ($ route , $ method );
273+
272274 $ iterable [$ version ][] = $ route ;
273275 }
274276 }
@@ -281,6 +283,8 @@ public function getIterableRoutes($version = null)
281283
282284 foreach ($ routes as $ data ) {
283285 foreach ($ data ['routeMap ' ] as list ($ route , $ parameters )) {
286+ $ route ['methods ' ] = $ this ->setRouteMethods ($ route , $ method );
287+
284288 $ iterable [$ version ][] = $ route ;
285289 }
286290 }
@@ -371,4 +375,19 @@ public function gatherRouteMiddlewares($route)
371375 // Route middleware in Lumen is not terminated.
372376 return [];
373377 }
378+
379+ /**
380+ * Append given method to the current route methods.
381+ *
382+ * @param array $route
383+ * @param string $method
384+ *
385+ * @return array
386+ */
387+ private function setRouteMethods ($ route , $ method )
388+ {
389+ return isset ($ route ['methods ' ])
390+ ? array_push ($ route ['methods ' ], $ method )
391+ : [$ method ];
392+ }
374393}
0 commit comments