main/build/router/controller/api.php

57 lines
787 B
PHP
Raw Permalink Normal View History

<?php
namespace router\controller;
use \api\core\Request;
use \api\core\Response;
use \api\core\Loader;
class api{
private $request;
private $response;
/* PRE-CALL
*
* @url<String> Calling URI
*
*/
public function __construct($matches){
/* (1) Rebuild request url */
$uri = $matches['module'].'/'.$matches['method'].$matches['uri_args'];
/* (2) Creates request */
$this->request = Loader::remote($uri);
}
/* CALL
*
*/
public function call(){
/* (1) Process response */
$this->response = $this->request->dispatch();
/* (2) Manages result */
if( $this->response instanceof Response )
echo $this->response->serialize();
return true;
}
/* POST-CALL
*
*/
public function __destruct(){
}
}