Browse Source

FetchData: Add time taken logging to response header

pull/26/head
Starbeamrainbowlabs 4 years ago
parent
commit
66eeb9010d
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
  1. 1
      api.php
  2. 18
      logic/Actions/FetchData.php

1
api.php

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
<?php
$start_time = microtime(true);
define("ROOT_DIR", dirname(__FILE__) . "/");

18
logic/Actions/FetchData.php

@ -13,10 +13,24 @@ class FetchData { @@ -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…
Cancel
Save