mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-24 06:43:01 +00:00
FetchData: Add time taken logging to response header
This commit is contained in:
parent
bbd08b439e
commit
66eeb9010d
2 changed files with 17 additions and 2 deletions
1
api.php
1
api.php
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
$start_time = microtime(true);
|
||||
|
||||
define("ROOT_DIR", dirname(__FILE__) . "/");
|
||||
|
||||
|
|
|
@ -13,10 +13,24 @@ class FetchData {
|
|||
$this->validator = new \AirQuality\Validator($_GET);
|
||||
}
|
||||
|
||||
public function handle() {
|
||||
public function handle() : Boolean {
|
||||
global $start_time;
|
||||
|
||||
// 1: Validate params
|
||||
$this->validator->is_datetime("datetime");
|
||||
$this->validator->run();
|
||||
|
||||
echo("Params valid!");
|
||||
// 2: Pull data from database
|
||||
|
||||
// 2.5: Validate data from database
|
||||
|
||||
// 3: Serialise data
|
||||
$response = json_encode("Coming soon");
|
||||
|
||||
// 4: Send response
|
||||
header("x-time-taken: " . (microtime(true) - $start_time) . "ms");
|
||||
header("content-type: application/json");
|
||||
echo($response);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue