Skip to content

Commit d0e07bf

Browse files
authored
Merge pull request #84 from niulingyun/master
custom headers
2 parents aec65f0 + 8171edb commit d0e07bf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Api.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ abstract class Api
4848
*/
4949
protected static $logLevel = Logger::DEBUG;
5050

51+
/**
52+
* @var array
53+
*/
54+
protected static $customHeaders;
55+
5156
/**
5257
* @var IAuth $auth
5358
*/
@@ -171,6 +176,22 @@ public static function setLogLevel($logLevel)
171176
self::$logLevel = $logLevel;
172177
}
173178

179+
/**
180+
* @param array $headers
181+
*/
182+
public static function setCustomHeaders(array $headers)
183+
{
184+
self::$customHeaders = $headers;
185+
}
186+
187+
/**
188+
* @return array
189+
*/
190+
public static function getCustomHeaders()
191+
{
192+
return self::$customHeaders;
193+
}
194+
174195
/**
175196
* @param string $method
176197
* @param string $uri
@@ -198,6 +219,11 @@ public function call($method, $uri, array $params = [], array $headers = [], $ti
198219
$headers = array_merge($headers, $authHeaders);
199220
}
200221
$headers['User-Agent'] = 'KuCoin-PHP-SDK/' . static::VERSION;
222+
223+
if (self::$customHeaders) {
224+
$headers = array_merge($headers, self::$customHeaders);
225+
}
226+
201227
$request->setHeaders($headers);
202228

203229
$requestId = uniqid();

0 commit comments

Comments
 (0)