Implemented phpmae:allowsGETRequests invokable-class config option

This commit is contained in:
2023-04-18 17:25:24 +02:00
parent 54bf188b0d
commit a6c7633495
+12 -3
View File
@@ -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 = [];
}
$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);