Skip to content

Commit 0d23de4

Browse files
authored
Use request->method for HTTP verb
1 parent 063a53e commit 0d23de4

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

system/Router/RouteCollection.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
namespace CodeIgniter\Router;
4141

42+
use Config\Services;
4243
use CodeIgniter\Autoloader\FileLocator;
4344
use CodeIgniter\Router\Exceptions\RouterException;
4445

@@ -234,7 +235,7 @@ class RouteCollection implements RouteCollectionInterface
234235
public function __construct(FileLocator $locator, $moduleConfig)
235236
{
236237
// Get HTTP verb
237-
$this->HTTPVerb = strtolower($_SERVER['REQUEST_METHOD'] ?? 'cli');
238+
$this->HTTPVerb = is_cli() ? 'cli' : Services::request()->getMethod();
238239

239240
$this->fileLocator = $locator;
240241

@@ -1115,12 +1116,6 @@ public function reverseRoute(string $search, ...$params)
11151116
{
11161117
$from = key($route['route']);
11171118
$to = $route['route'][$from];
1118-
1119-
// ignore closures
1120-
if (! is_string($to))
1121-
{
1122-
continue;
1123-
}
11241119

11251120
// Lose any namespace slash at beginning of strings
11261121
// to ensure more consistent match.

0 commit comments

Comments
 (0)