• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/classes/general/rest.php
  • Класс: CRestServer
  • Вызов: CRestServer::process
public function process()
{
	global $APPLICATION;

	$this->timeStart = microtime(true);

	if(!defined('BX24_REST_SKIP_SEND_HEADERS'))
	{
		CRestUtil::sendHeaders();
	}

	try
	{
		if($this->init())
		{
			$handler = new $this->class();
			/* @var IRestService $handler */
			$this->arServiceDesc = $handler->getDescription();

			$this->tokenCheck = $this->isTokenCheck();

			if($this->checkScope())
			{
				$APPLICATION->RestartBuffer();

				if($this->checkAuth())
				{
					BitrixRestUsageStatTable::log($this);


					if($this->tokenCheck)
					{
						return $this->processTokenCheckCall();
					}
					else
					{
						return $this->processCall();
					}
				}
				else
				{
					throw new AccessException();
				}
			}
			else
			{
				throw new RestException('Method not found!', RestException::ERROR_METHOD_NOT_FOUND, self::STATUS_NOT_FOUND);
			}
		}
	}
	catch(Exception $e)
	{
		$this->error = $e;

		if(!is_a($this->error, BitrixRestRestException::class))
		{
			MainApplication::getInstance()->getExceptionHandler()->writeToLog($e);

			$this->error = RestException::initFromException($this->error);
		}

		$ex = $APPLICATION->GetException();
		if($ex)
		{
			$this->error->setApplicationException($ex);
		}
	}

	if($this->error)
	{
		return $this->outputError();
	}

	return null;
}