/** @var RouteCollector */
protected $routeCollector;
- /**
- * @var string The HTTP method
- */
- private $httpMethod;
-
/**
* @var array Module parameters
*/
$this->logger = $logger;
$this->dice_profiler_threshold = $config->get('system', 'dice_profiler_threshold', 0);
- $httpMethod = $this->server['REQUEST_METHOD'] ?? self::GET;
-
- $this->httpMethod = in_array($httpMethod, self::ALLOWED_METHODS) ? $httpMethod : self::GET;
-
$this->routeCollector = isset($routeCollector) ?
$routeCollector :
new RouteCollector(new Std(), new GroupCountBased());
$this->parameters = [];
- $routeInfo = $dispatcher->dispatch($this->httpMethod, $cmd);
+ $routeInfo = $dispatcher->dispatch($this->args->getMethod(), $cmd);
if ($routeInfo[0] === Dispatcher::FOUND) {
$moduleClass = $routeInfo[1];
$this->parameters = $routeInfo[2];
} elseif ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
- if ($this->httpMethod === static::OPTIONS) {
+ if ($this->args->getMethod() === static::OPTIONS) {
// Default response for HTTP OPTIONS requests in case there is no special treatment
$moduleClass = Options::class;
} else {
$this->profiler->set(microtime(true) - $timestamp, 'init');
- switch ($this->server['REQUEST_METHOD'] ?? Router::GET) {
+ switch ($this->args->getMethod() ?? Router::GET) {
case Router::DELETE:
$this->delete($request);
break;
private function logError(int $errorno, string $error)
{
- $this->logger->info('API Error', ['no' => $errorno, 'error' => $error, 'method' => $this->server['REQUEST_METHOD'] ?? '', 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
+ $this->logger->info('API Error', ['no' => $errorno, 'error' => $error, 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
}
public function RecordNotFound()
public function run(array $request = [], bool $scopecheck = true): ResponseInterface
{
if ($scopecheck) {
- switch ($this->server['REQUEST_METHOD'] ?? Router::GET) {
+ switch ($this->args->getMethod()) {
case Router::DELETE:
case Router::PATCH:
case Router::POST:
header($_SERVER["SERVER_PROTOCOL"] . ' ' . $e->getCode() . ' ' . $e->getDescription());
if ($e->getCode() >= 400) {
- Logger::debug('Exit with error', ['code' => $e->getCode(), 'description' => $e->getDescription(), 'query' => DI::args()->getQueryString(), 'callstack' => System::callstack(20), 'method' => $_SERVER['REQUEST_METHOD'], 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
+ Logger::debug('Exit with error', ['code' => $e->getCode(), 'description' => $e->getDescription(), 'query' => DI::args()->getQueryString(), 'callstack' => System::callstack(20), 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
}
$tpl = Renderer::getMarkupTemplate('exception.tpl');