From 527738fa00b6a3761cb80287e5ae2019fc0ed2f1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 1 Mar 2019 17:46:12 +0000 Subject: [PATCH] Add version action. --- Changelog.md | 3 +++ README.md | 12 ++++++++++++ logic/Actions/Version.php | 36 ++++++++++++++++++++++++++++++++++++ version | 2 +- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 logic/Actions/Version.php diff --git a/Changelog.md b/Changelog.md index d461544..bb5a0fd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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)) diff --git a/README.md b/README.md index a7b0531..157ed3f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/logic/Actions/Version.php b/logic/Actions/Version.php new file mode 100644 index 0000000..d256df5 --- /dev/null +++ b/logic/Actions/Version.php @@ -0,0 +1,36 @@ +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; + } +} diff --git a/version b/version index 992ac75..b0c2058 100644 --- a/version +++ b/version @@ -1 +1 @@ -v0.5.1 +v0.5.2