DevicesApi
This commit is contained in:
parent
b4cfffc432
commit
5519d46ca2
@ -18,4 +18,6 @@ $router->any('/ajax', 'Ajax');
|
||||
$router->any('/log', 'Log');
|
||||
$router->any('/rooms', 'Rooms');
|
||||
|
||||
$router->get('/api/devices', 'DevicesApi@getAllDevices');
|
||||
|
||||
$router->run($_SERVER['REQUEST_METHOD'], '/'.(isset($_GET['url']) ? $_GET['url'] : ''));
|
||||
|
17
app/api/DevicesApi.php
Normal file
17
app/api/DevicesApi.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class DevicesApi extends ApiController{
|
||||
|
||||
public function getAllDevices(){
|
||||
$this->requireAuth();
|
||||
$response = [];
|
||||
|
||||
// TODO: process the request
|
||||
|
||||
$this->response($response);
|
||||
}
|
||||
|
||||
public function getDevicesByRoom($roomId){
|
||||
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ class ApiController {
|
||||
}
|
||||
}
|
||||
|
||||
function requireAuth(){
|
||||
private function requireAuth(){
|
||||
if (isset($this->headers['HTTP_AUTHORIZATION'])) {
|
||||
// TODO: call appropriate class/method
|
||||
$authManager = new AuthManager();
|
||||
@ -30,7 +30,7 @@ class ApiController {
|
||||
}
|
||||
}
|
||||
|
||||
function response($data = [], $httpCode = '200'){
|
||||
private function response($data = [], $httpCode = '200'){
|
||||
http_response_code($httpCode);
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user