Implemented phpmae:allowsGETRequests invokable-class config option
This commit is contained in:
+11
-2
@@ -142,12 +142,21 @@ class Engine implements RequestHandlerInterface {
|
||||
*/
|
||||
private function executeInvokableClass(RequestInterface $request, $args = null) {
|
||||
if (is_array($args) && count($args) > 0) {
|
||||
// Explicit arguments take precedence
|
||||
$input = $args;
|
||||
} else {
|
||||
} elseif ($request->getMethod() == 'GET') {
|
||||
// Handle GET requests only if class allows it
|
||||
if ($this->reader->getFirstValueBool($this->object, 'phpmae:allowsGETRequests'))
|
||||
$input = $request->getQueryParams();
|
||||
else
|
||||
return (new Response(405));
|
||||
} elseif ($request->getMethod() == 'POST') {
|
||||
// POST is always allowed
|
||||
$input = $request->getParsedBody();
|
||||
if (!is_array($input))
|
||||
$input = [];
|
||||
}
|
||||
} else
|
||||
return (new Response(405));
|
||||
|
||||
set_time_limit($this->container->has('execution_time_limit')
|
||||
? $this->container->get('execution_time_limit') : self::CLASS_TIME_LIMIT);
|
||||
|
||||
Reference in New Issue
Block a user