Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Slim/Interfaces/RouteCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ public function delete(string $path, callable|string $handler): RouteInterface;
*/
public function options(string $path, callable|string $handler): RouteInterface;

/**
* Register a QUERY route.
*
* @param string $path
* @param callable|string $handler
*
* @return RouteInterface
*/
public function query(string $path, callable|string $handler): RouteInterface;

/**
* Register a route for any HTTP method.
*
Expand Down
2 changes: 2 additions & 0 deletions Slim/Interfaces/RouterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function delete(string $path, callable|string $handler): RouteInterface;

public function options(string $path, callable|string $handler): RouteInterface;

public function query(string $path, callable|string $handler): RouteInterface;

public function any(string $pattern, callable|string $handler): RouteInterface;

/**
Expand Down
5 changes: 5 additions & 0 deletions Slim/Routing/RouteCollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function options(string $path, callable|string $handler): RouteInterface
return $this->map(['OPTIONS'], $path, $handler);
}

public function query(string $path, callable|string $handler): RouteInterface
{
return $this->map(['QUERY'], $path, $handler);
}

public function any(string $pattern, callable|string $handler): RouteInterface
{
return $this->map(['*'], $pattern, $handler);
Expand Down
2 changes: 2 additions & 0 deletions tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public static function lowerCaseRequestMethodsProvider(): array
['patch'],
['delete'],
['options'],
['query'],
];
}

Expand Down Expand Up @@ -222,6 +223,7 @@ public static function upperCaseRequestMethodsProvider(): array
['PATCH'],
['DELETE'],
['OPTIONS'],
['QUERY'],
];
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Routing/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ function () {
},
['PUT'],
],
[
'query',
'/query',
function () {
return 'query_handler';
},
['QUERY'],
],
];
}

Expand Down