mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
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:
committed by
Alexander Kukushkin
parent
5ef01cfdfa
commit
53715e689a
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user