Browse Source

Add version action.

pull/26/head
Starbeamrainbowlabs 4 years ago
parent
commit
527738fa00
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
  1. 3
      Changelog.md
  2. 12
      README.md
  3. 36
      logic/Actions/Version.php
  4. 2
      version

3
Changelog.md

@ -1,5 +1,8 @@ @@ -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))

12
README.md

@ -80,6 +80,18 @@ Instead, enter your configuration details into `data/settings.toml`, which overr @@ -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

@ -0,0 +1,36 @@ @@ -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;
}
}

2
version

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

Loading…
Cancel
Save