Skip to content

Commit a1a09c1

Browse files
committed
Allow paths to be specified for custom events URIs
1 parent 034300c commit a1a09c1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/LaunchDarkly/EventProcessor.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ public function __construct($apiKey, $options = array()) {
2020
$this->_host = 'events.launchdarkly.com';
2121
$this->_port = 443;
2222
$this->_ssl = true;
23+
$this->_path = '';
2324
}
2425
else {
25-
$url = parse_url($options['events_uri']);
26+
$url = parse_url(rtrim($options['events_uri'],'/'));
2627
$this->_host = $url['host'];
2728
$this->_ssl = $url['scheme'] === 'https';
2829
if (isset($url['port'])) {
@@ -31,6 +32,12 @@ public function __construct($apiKey, $options = array()) {
3132
else {
3233
$this->_port = $this->_ssl ? 443 : 80;
3334
}
35+
if (isset($url['path'])) {
36+
$this->_path = $url['path'];
37+
}
38+
else {
39+
$this->_path = '';
40+
}
3441
}
3542

3643
$this->_capacity = $options['capacity'];
@@ -77,7 +84,7 @@ private function createArgs($payload) {
7784
$args.= " -H 'User-Agent: PHPClient/" . LDClient::VERSION . "'";
7885
$args.= " -H 'Accept: application/json'";
7986
$args.= " -d " . escapeshellarg($payload);
80-
$args.= " " . escapeshellarg($scheme . $this->_host . ":" . $this->_port . "/bulk");
87+
$args.= " " . escapeshellarg($scheme . $this->_host . ":" . $this->_port . $this->_path . "/bulk");
8188
return $args;
8289
}
8390

0 commit comments

Comments
 (0)