Implemented phpmae:allowsGETRequests invokable-class config option
This commit is contained in:
+12
-3
@@ -142,12 +142,21 @@ class Engine implements RequestHandlerInterface {
|
|||||||
*/
|
*/
|
||||||
private function executeInvokableClass(RequestInterface $request, $args = null) {
|
private function executeInvokableClass(RequestInterface $request, $args = null) {
|
||||||
if (is_array($args) && count($args) > 0) {
|
if (is_array($args) && count($args) > 0) {
|
||||||
|
// Explicit arguments take precedence
|
||||||
$input = $args;
|
$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();
|
$input = $request->getParsedBody();
|
||||||
if (!is_array($input))
|
if (!is_array($input))
|
||||||
$input = [];
|
$input = [];
|
||||||
}
|
} else
|
||||||
|
return (new Response(405));
|
||||||
|
|
||||||
set_time_limit($this->container->has('execution_time_limit')
|
set_time_limit($this->container->has('execution_time_limit')
|
||||||
? $this->container->get('execution_time_limit') : self::CLASS_TIME_LIMIT);
|
? $this->container->get('execution_time_limit') : self::CLASS_TIME_LIMIT);
|
||||||
|
|||||||
Reference in New Issue
Block a user