Ejemplo n.º 1
0
 /**
  * @param Request $request
  *
  * @return BindingInterface
  *
  * @throws RequestNotSupportedException
  */
 private function findBinding(Request $request)
 {
     foreach ($this->bindings as $binding) {
         if ($binding->support($request)) {
             return $binding;
         }
     }
     throw RequestNotSupportedException::make($this->location->name(), $request);
 }
Ejemplo n.º 2
0
 /**
  * @param LocationInterface $location
  * @param Request           $request
  *
  * @return AMQPMessage
  */
 private function createMessage(LocationInterface $location, Request $request)
 {
     $encoded = $this->encoder->encode($request->getArguments());
     return new AMQPMessage($encoded->getBody(), ['content_type' => $encoded->getType(), 'message_id' => uniqid('', true), 'timestamp' => time(), 'application_headers' => new AMQPTable(array_merge($request->getHeaders(), ['to' => $location->name(), 'topic' => $request->getTopic(), 'version' => $request->getVersion()]))]);
 }
Ejemplo n.º 3
0
 /**
  * @param LocationInterface $location
  *
  * @return string
  */
 private function getRequestUrl(LocationInterface $location)
 {
     if ($url = $location->url(['https', 'http'])) {
         return $url;
     }
     throw new \InvalidArgumentException(sprintf('Endpoint "%s" does not support neither "https" nor "http" protocols', $location->name()));
 }