public function __construct($options = array()) { $this->configureErrorHandler(); // configure $mergedOptions = ['env' => isset($_SERVER['ENV']) ? $_SERVER['ENV'] : 'development', 'config.path' => '../config', 'date.timezone' => 'UTC', 'route.dispatcher' => 'simple', 'response.chunkSize' => 4096]; $optionsPath = isset($options['config.path']) ? $options['config.path'] : $mergedOptions['config.path']; $mergedOptions = Options::create($mergedOptions, $mergedOptions['env'])->mergeFile($optionsPath . '/config.php')->merge($options)->toArray(); parent::__construct($mergedOptions); }
public function __construct(array $options = []) { $options = App::getInstance()['nginx'] ?: []; parent::__construct($options); $this->routeMap(['GET'], '/', [$this, 'search']); $this->routeMap(['POST'], '/', [$this, 'create']); $this->routeMap(['DELETE'], '/', [$this, 'delete']); $this->routeMap(['GET'], '/reload', [$this, 'reload']); $this->routeMap(['POST'], '/{normalized}/upstream', [$this, 'upstreamCreate']); $this->routeMap(['DELETE'], '/{normalized}/upstream', [$this, 'upstreamDelete']); }
public function testRoutes() { $bundle = new Bundle(); $getRoute = function () { }; $bundle->routeGet('/get', $getRoute); $postRoute = function () { }; $bundle->routePost('/post', $getRoute); $putRoute = function () { }; $bundle->routePut('/put', $getRoute); $dumped = $bundle->dumpRoutes(); $this->assertEquals(['GET'], $dumped[0]['methods']); $this->assertEquals('/get', $dumped[0]['pattern']); $this->assertEquals($getRoute, $dumped[0]['handler']); $this->assertEquals(['POST'], $dumped[1]['methods']); $this->assertEquals('/post', $dumped[1]['pattern']); $this->assertEquals($postRoute, $dumped[1]['handler']); $this->assertEquals(['PUT'], $dumped[2]['methods']); $this->assertEquals('/put', $dumped[2]['pattern']); $this->assertEquals($putRoute, $dumped[2]['handler']); }