Skip to content

Commit bd2f9b7

Browse files
committed
Seperate GetETag from standard Get
1 parent 9d57e68 commit bd2f9b7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sumologic/sumologic_client.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (s *Client) PostRawPayload(urlPath string, payload string) ([]byte, error)
154154
}
155155

156156
func (s *Client) Put(urlPath string, payload interface{}) ([]byte, error) {
157-
_, etag, _ := s.Get(urlPath)
157+
etag, _ := s.GetETag(urlPath)
158158

159159
body, err := json.Marshal(payload)
160160
if err != nil {
@@ -219,6 +219,20 @@ func (s *Client) GetWithErrOpt(urlPath string, return404Err bool) ([]byte, strin
219219
return d, resp.Header.Get("ETag"), nil
220220
}
221221

222+
func (s *Client) GetETag(urlPath string) (string, error) {
223+
req, err := s.createSumoRequest(http.MethodGet, urlPath, nil)
224+
if err != nil {
225+
return "", err
226+
}
227+
228+
resp, err := s.doSumoRequest(req)
229+
if err != nil {
230+
return "", err
231+
}
232+
233+
return resp.Header.Get("ETag"), nil
234+
}
235+
222236
func (s *Client) Delete(urlPath string) ([]byte, error) {
223237
req, err := s.createSumoRequest(http.MethodDelete, urlPath, nil)
224238
if err != nil {

0 commit comments

Comments
 (0)