$this->sender->send_error_plain(405,"Error: The devices-near action only takes a POST request, but you sent a {$_SERVER["REQUEST_METHOD"]} request. The parameters 'longitude' and 'latitude' should be specified in the POST body, and 'count' as a regular GET parameter.\nExample POST body (without quotes): 'latitude=12.345678&longitude=98.765432'\nDon't forget that the content-type header should be set to 'application/x-www-form-urlencoded'.",[
["x-time-taken",$this->perfcounter->render()]
]);
returnfalse;
}
// 1: Validate params
$this->validator_get->is_numberish("count");
$this->validator_get->run();
$this->validator_post->is_numberish("latitude");
$this->validator_post->is_numberish("longitude");
$this->validator_post->run();
// 2: Pull data from database
$this->perfcounter->start("sql");
$data=$this->device_repo->get_near_location(
floatval($_POST["latitude"]),
floatval($_POST["longitude"]),
intval($_GET["count"])
);
$this->perfcounter->end("sql");
// 3: Serialise data
$this->perfcounter->start("encode");
$response=json_encode($data);
$this->perfcounter->end("encode");
// 4: Send response
// Send a cache-control header, but only in production mode