예제 #1
0
파일: Pipe.php 프로젝트: virusvn/fusio
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $response = $this->processor->execute($configuration->get('source'), $request, $context);
     $visitor = new StdClassSerializeVisitor();
     $traverser = new GraphTraverser();
     $traverser->traverse($response->getBody(), $visitor);
     $importer = $this->importerManager->getImporterByInstance('PSX\\Data\\Record\\Importer\\Record');
     $body = $importer->import(new Record(), $visitor->getObject());
     return $this->processor->execute($configuration->get('destination'), $request->withBody($body), $context);
 }
예제 #2
0
파일: Condition.php 프로젝트: virusvn/fusio
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $condition = $configuration->get('condition');
     $language = new ExpressionLanguage($this);
     $values = array('rateLimit' => new RateLimit($this->connection, $context), 'app' => $context->getApp(), 'routeId' => $context->getRouteId(), 'uriFragments' => $request->getUriFragments(), 'parameters' => $request->getParameters(), 'body' => new Accessor(new Validate(), $request->getBody()));
     if (!empty($condition) && $language->evaluate($condition, $values)) {
         return $this->processor->execute($configuration->get('true'), $request, $context);
     } else {
         return $this->processor->execute($configuration->get('false'), $request, $context);
     }
 }
예제 #3
0
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $key = md5($configuration->get('action'));
     $item = $this->cache->getItem($key);
     if (!$item->isHit()) {
         $response = $this->processor->execute($configuration->get('action'), $request, $context);
         $item->set($response, $configuration->get('expire'));
         $this->cache->save($item);
     } else {
         $response = $item->get();
     }
     return $response;
 }
예제 #4
0
 private function executeAction(RecordInterface $record, Version $version)
 {
     $actionId = $this->getActiveMethod()->getAction();
     if ($actionId > 0) {
         try {
             $context = new FusioContext($this->context->get('fusio.routeId'), $this->app);
             $request = new Request($this->request, $this->uriFragments, $this->getParameters(), $record);
             $response = $this->processor->execute($actionId, $request, $context);
             $statusCode = $response->getStatusCode();
             $headers = $response->getHeaders();
             if (!empty($statusCode)) {
                 $this->setResponseCode($statusCode);
             }
             if (!empty($headers)) {
                 foreach ($headers as $name => $value) {
                     $this->setHeader($name, $value);
                 }
             }
             return $response->getBody();
         } catch (\Exception $e) {
             $this->apiLogger->appendError($this->logId, $e);
             throw $e;
         }
     } else {
         throw new StatusCode\ServiceUnavailableException('No action provided');
     }
 }
예제 #5
0
파일: Composite.php 프로젝트: virusvn/fusio
 public function handle(Request $request, Parameters $configuration, Context $context)
 {
     $this->processor->execute($configuration->get('in'), $request, $context);
     return $this->processor->execute($configuration->get('out'), $request, $context);
 }