diff --git a/app/Routes.php b/app/Routes.php index fa54b74..9c99fa4 100644 --- a/app/Routes.php +++ b/app/Routes.php @@ -23,5 +23,9 @@ $router->post('/api/login', 'AuthApi@login'); $router->post('/api/HA', 'GoogleHome@response'); +// examples +$router->any('/api/example', 'ExampleApi@example'); +$router->any('/example', 'ExampleController@index'); +$router->any('/example/subpage', 'ExampleController@subpage'); $router->run($_SERVER['REQUEST_METHOD'], '/'.(isset($_GET['url']) ? $_GET['url'] : '')); diff --git a/app/api/ExampleApi.php b/app/api/ExampleApi.php new file mode 100644 index 0000000..0fe5727 --- /dev/null +++ b/app/api/ExampleApi.php @@ -0,0 +1,24 @@ +requireAuth(); + // if user is logged in, next lines will be processed + // otherwise script get terminated with 401 UNAUTHORIZED + + + // input data are stored in $this->input + // in this example we just copy input to response + $response = $this->input; + + + // this method returns response as json + $this->response($response); + // you can specify returned http code by second optional parameter + // default value is 200 + // $this->response($response, $httpCode); + } + +} diff --git a/app/controllers/ExampleController.php b/app/controllers/ExampleController.php new file mode 100644 index 0000000..dbafc2b --- /dev/null +++ b/app/controllers/ExampleController.php @@ -0,0 +1,18 @@ +