Example #1
0
 /**
  * Request constructor.
  * @param string $method
  * @param string $path
  * @param Config $config
  * @param string $body
  */
 public function __construct($method, $path, Config $config, $body = null)
 {
     $this->c = $config;
     $this->params = new Params();
     $this->method = strtoupper($method);
     $this->path = $path;
     if ('' !== ($dc = $config->getDatacenter())) {
         $this->params['dc'] = $dc;
     }
     if (0 !== ($wait = $config->getWaitTime())) {
         $this->params['wait'] = $wait;
     }
     if ('' !== ($token = $config->getToken())) {
         if ($config->isTokenInHeader()) {
             $this->headers['X-Consul-Token'] = $token;
         } else {
             $this->params['token'] = $token;
         }
     }
     $this->body = $body;
 }