Exemplo n.º 1
0
 public function dispatch()
 {
     try {
         $router = new Router($this->app);
         //ルーティングに沿ったcontrollerを設定
         $router->routing();
         $this->setNotFoundAction();
         $this->app->handle();
     } catch (\Exception $e) {
         throw $e;
     } catch (\Error $e) {
         throw $e;
     }
 }
Exemplo n.º 2
0
 public function handle($uri = null)
 {
     if ($this->apibird->corsEnabled()) {
         $this->options('^(/.*)$', function () {
             return '';
         });
     }
     return parent::handle($uri);
 }
Exemplo n.º 3
0
try {
    /**
     * Read the configuration
     */
    $config = (include __DIR__ . "/../config/config.php");
    /**
     * Include Services
     */
    include APP_PATH . '/config/services.php';
    /**
     * Include Autoloader
     */
    include APP_PATH . '/config/loader.php';
    /**
     * Starting the application
     * Assign service locator to the application
     */
    $app = new Micro($di);
    /**
     * Include Application
     */
    include APP_PATH . '/app.php';
    include APP_PATH . '/users.php';
    include APP_PATH . '/todoEntries.php';
    /**
     * Handle the request
     */
    $app->handle();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Exemplo n.º 4
0
<?php

error_reporting(E_ALL);
use Phalcon\Mvc\Micro as App;
define('APP_PATH', realpath('../app'));
require APP_PATH . '/config/loader.php';
require APP_PATH . '/config/services.php';
//try {
$app = new App();
$app->setDI($di);
require APP_PATH . '/handlers.php';
$response = $app->handle();
if ($response instanceof Phalcon\Http\ResponseInterface) {
    $response->send();
}
//} catch (Exception $e) {
//	echo $app->view->render('errors/500', array(
//		'exception' => $e
//	));
//}
Exemplo n.º 5
0
 public function testMicroStopMiddlewareClasses()
 {
     $this->specify("Micro middleware events don't work as expected", function () {
         $app = new Micro();
         $app->map("/api/site", function () {
             return true;
         });
         $middleware = new \MyMiddlewareStop();
         $app->before($middleware);
         $app->before($middleware);
         $app->after($middleware);
         $app->after($middleware);
         $app->finish($middleware);
         $app->finish($middleware);
         $app->handle("/api/site");
         expect($middleware->getNumber())->equals(3);
     });
 }
Exemplo n.º 6
0
 /**
  * Handle the whole restful request.
  *
  * @param string|null $uri
  * @return mixed
  * @throws \Parest\Exception\BuildException
  */
 public function handle($uri = null)
 {
     try {
         if (!$this->hasService('access')) {
             throw new BuildException('The access service is not defined');
         }
         $clientRole = call_user_func($this->_clientIdentificationHandler);
         if (!is_object($clientRole) || !$clientRole instanceof Role) {
             throw new BuildException('The client authorization handler return value is not a valid access role');
         }
         $this->access->setClientRole($clientRole);
         return parent::handle($uri);
     } catch (ResourceException $e) {
         $e->response()->send();
     } catch (BuildException $e) {
         throw $e;
     } catch (Exception $e) {
         $exception = new InternalServerErrorException();
         $exception->response()->send();
     }
     return false;
 }