Air-Quality-Web/logic/Actions/Version.php

38 lines
735 B
PHP
Raw Normal View History

2019-03-01 17:46:12 +00:00
<?php
namespace AirQuality\Actions;
use \SBRL\TomlConfig;
class Version implements IAction {
/** @var TomlConfig */
private $settings;
2019-06-20 23:02:26 +00:00
/** @var \SBRL\PerformanceCounter */
private $perfcounter;
2019-03-01 17:46:12 +00:00
public function __construct(
2019-06-20 23:02:26 +00:00
TomlConfig $in_settings,
\SBRL\PerformanceCounter $in_perfcounter) {
2019-03-01 17:46:12 +00:00
$this->settings = $in_settings;
2019-06-20 23:02:26 +00:00
$this->perfcounter = $in_perfcounter;
2019-03-01 17:46:12 +00:00
}
public function handle() : bool {
global $start_time;
// 1: Parse markdown
$result = file_get_contents(ROOT_DIR."version");
// 2: Send response
header("content-length: " . strlen($result));
header("content-type: text/plain");
2019-06-20 23:02:26 +00:00
header("x-time-taken: " . $this->perfcounter->render());
2019-03-01 17:46:12 +00:00
echo($result);
return true;
}
}