Blame view

app/library/App/Bootstrap/MiddlewareBootstrap.php 987 Bytes
15479603   Alex Savenko   initialize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  <?php
  
  namespace App\Bootstrap;
  
  use App\BootstrapInterface;
  use Phalcon\Config;
  use Phalcon\DiInterface;
  use PhalconRest\Api;
  use PhalconApi\Middleware\AuthenticationMiddleware;
  use PhalconRest\Middleware\AuthorizationMiddleware;
  use PhalconApi\Middleware\CorsMiddleware;
  use PhalconRest\Middleware\FractalMiddleware;
  use PhalconApi\Middleware\NotFoundMiddleware;
  use PhalconApi\Middleware\OptionsResponseMiddleware;
  use PhalconApi\Middleware\UrlQueryMiddleware;
  
  class MiddlewareBootstrap implements BootstrapInterface
  {
      public function run(Api $api, DiInterface $di, Config $config)
      {
          $api
              ->attach(new CorsMiddleware($config->cors->allowedOrigins->toArray()))
              ->attach(new OptionsResponseMiddleware)
              ->attach(new NotFoundMiddleware)
              ->attach(new AuthenticationMiddleware)
              ->attach(new AuthorizationMiddleware)
              ->attach(new FractalMiddleware)
              ->attach(new UrlQueryMiddleware);
      }
  }