mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-12-27 11:14:56 +00:00
Add version action.
This commit is contained in:
parent
e260835850
commit
527738fa00
4 changed files with 52 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.5.2 - 1st March 2019
|
||||||
|
- [API] Added `version` action
|
||||||
|
|
||||||
## v0.5.1 - 26th February 2019
|
## v0.5.1 - 26th February 2019
|
||||||
- Fixed issue with non-linear sensor reading reports ([#15](https://github.com/ConnectedHumber/Air-Quality-Web/issues/15))
|
- Fixed issue with non-linear sensor reading reports ([#15](https://github.com/ConnectedHumber/Air-Quality-Web/issues/15))
|
||||||
|
|
||||||
|
|
12
README.md
12
README.md
|
@ -80,6 +80,18 @@ Instead, enter your configuration details into `data/settings.toml`, which overr
|
||||||
## API
|
## 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:
|
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
|
### fetch-data
|
||||||
> Fetches air quality data from the system for a specific data type at a specific date and time.
|
> 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
36
logic/Actions/Version.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
2
version
2
version
|
@ -1 +1 @@
|
||||||
v0.5.1
|
v0.5.2
|
||||||
|
|
Loading…
Reference in a new issue