2019-05-16 16:31:35 +00:00
< ? php
namespace AirQuality\Actions ;
use \SBRL\TomlConfig ;
2019-06-13 19:58:36 +00:00
class Index implements IAction {
2019-05-16 16:31:35 +00:00
/** @var TomlConfig */
private $settings ;
2019-06-20 23:02:26 +00:00
/** @var \SBRL\PerformanceCounter */
private $perfcounter ;
2019-05-16 16:31:35 +00:00
/** @var \ParsedownExtra */
private $parsedown_ext ;
public function __construct (
2019-06-20 23:02:26 +00:00
TomlConfig $in_settings ,
\SBRL\PerformanceCounter $in_perfcounter ) {
2019-05-16 16:31:35 +00:00
$this -> settings = $in_settings ;
2019-06-20 23:02:26 +00:00
$this -> perfcounter = $in_perfcounter ;
2019-05-16 16:31:35 +00:00
}
public function handle () : bool {
global $start_time ;
2019-06-20 23:02:26 +00:00
$this -> perfcounter -> start ( " handle " );
2019-05-16 16:31:35 +00:00
// 1: Parse markdown
$result = " Welcome to the Air Quality Web HTTP API!
Although the web interface is the default thing you see , it actually uses this HTTP API as a backend - which can be interacted with directly .
2020-12-12 13:58:54 +00:00
Official usage documentation for the latest version of the API can be found here : https :// sensors . connectedhumber . org / __nightdocs / 05 - API - Docs . html
2019-05-16 16:31:35 +00:00
Note that if you have deployed your own version of the air quality web interface , you will need to ensure you 're up-to-date with the latest commits in the \"master\" branch, otherwise the HTTP API documentation may not be completely accurate with respect to the version you' re running .
" ;
// 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-05-16 16:31:35 +00:00
echo ( $result );
return true ;
}
}