Exemple #1
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Node\HttpHub::handleHttpCargo($cargo)
  */
 protected function handleHttpCargo(HttpCargoInterface $cargo) : CargoInterface
 {
     $path = $cargo->getRequestUri()->getPath();
     $length = strlen($this->basePath);
     if (strncmp($path, $this->basePath, $length) === 0) {
         $path = substr($path, $length);
         if (strlen($path)) {
             return $this->handlePath($cargo, $path);
         }
         return $cargo->setStatusCode(Http::STATUS_NOT_FOUND_404);
     }
     return $cargo;
 }
Exemple #2
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Node\HttpHub::handleHttpCargo($cargo)
  */
 public function handleHttpCargo(HttpCargoInterface $cargo) : CargoInterface
 {
     $segments = explode('/', trim($cargo->getRequestUri()->getPath(), '/'));
     $count = count($segments);
     if (isset($this->routeTree[$count]) && false !== ($found = $this->findHandler($segments, $this->routeTree[$count], []))) {
         $cargo->getRequestParameters()->setFromArray($found[static::KEY_PARAMETERS]);
         return $this->getHandler($found[static::KEY_HANDLER])->handle($cargo);
     }
     return $cargo;
 }