diff options
author | Corey Hulen <corey@hulen.com> | 2018-06-12 10:16:39 -0700 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2018-06-12 10:16:39 -0700 |
commit | 656c8a62d145fc565e9a98e060329239d2d59fbd (patch) | |
tree | b4922cbf8b14992c353742e9e4225d7736a2e3a3 /model/client4.go | |
parent | 4ea7f6a2f7e61356996a3dfa85169f8db5d4d064 (diff) | |
download | chat-656c8a62d145fc565e9a98e060329239d2d59fbd.tar.gz chat-656c8a62d145fc565e9a98e060329239d2d59fbd.tar.bz2 chat-656c8a62d145fc565e9a98e060329239d2d59fbd.zip |
Prototype for CBA (#8475)
* Prototype for CBA
* Fixing gofmt issues
* Do not require password if logging in with certificate
* Fixing issues from feedback
* Adding unit tests
* Fixing feedback
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/model/client4.go b/model/client4.go index 8096b2364..f5a856835 100644 --- a/model/client4.go +++ b/model/client4.go @@ -57,6 +57,7 @@ type Client4 struct { HttpClient *http.Client // The http client AuthToken string AuthType string + HttpHeader map[string]string // Headers to be copied over for each request } func closeBody(r *http.Response) { @@ -78,7 +79,7 @@ func (c *Client4) Must(result interface{}, resp *Response) interface{} { } func NewAPIv4Client(url string) *Client4 { - return &Client4{url, url + API_URL_SUFFIX, &http.Client{}, "", ""} + return &Client4{url, url + API_URL_SUFFIX, &http.Client{}, "", "", map[string]string{}} } func BuildErrorResponse(r *http.Response, err *AppError) *Response { @@ -423,6 +424,13 @@ func (c *Client4) DoApiRequest(method, url, data, etag string) (*http.Response, rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken) } + if c.HttpHeader != nil && len(c.HttpHeader) > 0 { + + for k, v := range c.HttpHeader { + rq.Header.Set(k, v) + } + } + if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil { return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0) } else if rp.StatusCode == 304 { |