Beispiel #1
0
 /**
  * Dispatches the request and, if the Api is not under test, sends the
  * response back to the User Agent.
  *
  * @param Request $request
  * @param Response $response
  * @return void
  */
 public function dispatch(Request $request = null, Response $response = null)
 {
     if (!$request) {
         $request = new Request();
         $request->initialise($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES, file_get_contents("php://input"));
     }
     if (!$response) {
         $response = new Response();
     }
     $this->services->initialise($request, $response);
     $router = new Router(new Cache($this->cacheFile), new UrlTools());
     $dispatcher = new Dispatcher($this, $request, $response, $router, new Sender($request, $response));
     $dispatcher->dispatch();
 }
Beispiel #2
0
 protected function dispatch()
 {
     ob_start();
     $this->dispatcher->dispatch();
     return ob_get_clean();
 }