Pass the consul token as a header (#513)

Headers are now the prefered way to pass the token to the consul API - https://www.consul.io/api/index.html#authentication
This commit is contained in:
Andrew Colin Kissa
2017-09-07 16:59:49 +02:00
committed by Alexander Kukushkin
parent 5ef01cfdfa
commit 53715e689a
+2
View File
@@ -82,6 +82,8 @@ class HTTPClient(object):
kwargs['timeout'] = (float(params['wait'][:-1]) if 'wait' in params else 300) + 1
else:
kwargs['timeout'] = self._read_timeout
if isinstance(params, dict) and 'token' in params and params['token']:
kwargs['headers'] = {'X-Consul-Token': params.pop('token')}
return callback(self.response(self.http.request(method.upper(), self.uri(path, params), **kwargs)))
return wrapper