@@ -23,10 +23,9 @@ const (
2323
2424// Client represents an API client
2525type Client struct {
26- userName string
27- password string
28- httpClient * http.Client
29- contentType string
26+ userName string
27+ password string
28+ httpClient * http.Client
3029}
3130
3231// New creates ands returns a new client configured with the specified user and password
@@ -154,29 +153,23 @@ func (c *Client) PerformJSONPutUploadRequest(url string, requestBody io.Reader)
154153 return c .performJSONRequest (request )
155154}
156155
157- func (c * Client ) SetContentType (ct string ) {
158- c .contentType = ct
159- }
160-
161- func (c * Client ) GetContentType () string {
162- if c .contentType == "" {
163- return "application/json"
164- }
165- return c .contentType
166- }
167-
168156// Adds common headers to the specified request
169- func (c * Client ) addJSONRequestHeaders (request * http.Request ) * http.Request {
157+ func (c * Client ) AddRequestHeaders (request * http.Request ) * http.Request {
170158 request .SetBasicAuth (c .userName , c .password )
171159 request .Header .Set ("Accept" , "application/json" )
172- request .Header .Set ("Content-Type" , c . GetContentType () )
160+ request .Header .Set ("Content-Type" , "application/json" )
173161
174162 return request
175163}
176164
177165// Performs the specified HTTP request and returns the response through handleResponse()
178166func (c * Client ) performJSONRequest (request * http.Request ) ([]byte , error ) {
179- c .addJSONRequestHeaders (request )
167+ c .AddRequestHeaders (request )
168+ return c .PerformRequest (request )
169+ }
170+
171+ // Performs the specified HTTP request and returns the response through handleResponse()
172+ func (c * Client ) PerformRequest (request * http.Request ) ([]byte , error ) {
180173 response , err := c .httpClient .Do (request )
181174
182175 if err != nil {
0 commit comments