Add version action.

This commit is contained in:
Starbeamrainbowlabs 2019-03-01 17:46:12 +00:00
parent e260835850
commit 527738fa00
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
4 changed files with 52 additions and 1 deletions

View File

@ -1,5 +1,8 @@
# Changelog
## v0.5.2 - 1st March 2019
- [API] Added `version` action
## v0.5.1 - 26th February 2019
- Fixed issue with non-linear sensor reading reports ([#15](https://github.com/ConnectedHumber/Air-Quality-Web/issues/15))

View File

@ -80,6 +80,18 @@ Instead, enter your configuration details into `data/settings.toml`, which overr
## API
The server-side API is accessed through `api.php`, and supports a number of GET parameters. The most important of these is the `action` parameter, Which determines what the API will do. The following values are supported:
### version
> Returns the version of the application.
_No parameters are currently supported by this action._
Examples:
```
https://example.com/path/to/api.php?action=version
```
### fetch-data
> Fetches air quality data from the system for a specific data type at a specific date and time.

36
logic/Actions/Version.php Normal file
View File

@ -0,0 +1,36 @@
<?php
namespace AirQuality\Actions;
use \SBRL\TomlConfig;
use \AirQuality\PerfFormatter;
class Version implements IAction {
/** @var TomlConfig */
private $settings;
public function __construct(
TomlConfig $in_settings) {
$this->settings = $in_settings;
}
public function handle() : bool {
global $start_time;
$start_handle = microtime(true);
// 1: Parse markdown
$result = file_get_contents(ROOT_DIR."version");
// 2: Send response
header("content-length: " . strlen($result));
header("content-type: text/plain");
header("x-time-taken: " . PerfFormatter::format_perf_data($start_time, $start_handle, null));
echo($result);
return true;
}
}

View File

@ -1 +1 @@
v0.5.1
v0.5.2