Esempio n. 1
0
 /**
  * Dispatch a request.
  *
  * @param \Sunel\Api\Http\Request $request
  *
  * @throws \Exception
  *
  * @return \Sunel\Api\Http\Response
  */
 public function dispatch(Request $request)
 {
     $this->currentRoute = null;
     $accept = $this->accept->parse($request);
     $this->container->instance('request', $request);
     $this->routesDispatched++;
     try {
         if (!isset($this->routes[$accept['version']])) {
             throw new UnknownVersionException();
         }
         $routes = $this->routes[$accept['version']];
         $this->container->setDispatcher(new GroupCountBased($routes->getData()));
         $this->normalizeRequestUri($request);
         $response = $this->container->dispatch($request);
     } catch (\Exception $exception) {
         $response = $this->exception->handle($exception);
     }
     return $this->prepareResponse($response, $request, $accept['format']);
 }
Esempio n. 2
0
 /**
  * Setup the configuration.
  *
  * @return void
  */
 protected function setupConfig()
 {
     $config = new Config(\Mage::getConfig()->getNode('global/api3')->asArray());
     $this->app->instance('config', $config);
 }