Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *Client) StubFor(stubRule *StubRule) error {
if err != nil {
return fmt.Errorf("stub request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

if res.StatusCode != http.StatusCreated {
bodyBytes, err := io.ReadAll(res.Body)
Expand All @@ -56,14 +56,14 @@ func (c *Client) StubFor(stubRule *StubRule) error {
func (c *Client) Clear() error {
req, err := http.NewRequest(http.MethodDelete, fmt.Sprintf("%s/%s", c.url, wiremockAdminMappingsURN), nil)
if err != nil {
return fmt.Errorf("build cleare Request error: %w", err)
return fmt.Errorf("build clear Request error: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just looking at the code and noticed this. It makes me happy to see it fixed 😄

}

res, err := (&http.Client{}).Do(req)
if err != nil {
return fmt.Errorf("clear Request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

if res.StatusCode != http.StatusOK {
return fmt.Errorf("bad response status: %d", res.StatusCode)
Expand All @@ -78,7 +78,7 @@ func (c *Client) Reset() error {
if err != nil {
return fmt.Errorf("reset Request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

if res.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(res.Body)
Expand All @@ -98,7 +98,7 @@ func (c *Client) ResetAllScenarios() error {
if err != nil {
return fmt.Errorf("reset all scenarios Request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

if res.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(res.Body)
Expand All @@ -123,7 +123,7 @@ func (c *Client) GetCountRequests(r *Request) (int64, error) {
if err != nil {
return 0, fmt.Errorf("get count requests: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand Down Expand Up @@ -162,7 +162,7 @@ func (c *Client) GetAllRequests() (*journal.GetAllRequestsResponse, error) {
if err != nil {
return nil, fmt.Errorf("get all requests: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand All @@ -187,7 +187,7 @@ func (c *Client) GetRequestByID(requestID string) (*journal.GetRequestResponse,
if err != nil {
return nil, fmt.Errorf("get request by id: build request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand Down Expand Up @@ -217,7 +217,7 @@ func (c *Client) FindRequestsByCriteria(r *Request) (*journal.FindRequestsByCrit
if err != nil {
return nil, fmt.Errorf("find requests by criteria: request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand All @@ -242,7 +242,7 @@ func (c *Client) FindUnmatchedRequests() (*journal.FindUnmatchedRequestsResponse
if err != nil {
return nil, fmt.Errorf("find unmatched requests: request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand Down Expand Up @@ -272,7 +272,7 @@ func (c *Client) DeleteAllRequests() error {
if err != nil {
return fmt.Errorf("delete all requests: request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

if res.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(res.Body)
Expand All @@ -295,7 +295,7 @@ func (c *Client) DeleteRequestByID(requestID string) error {
if err != nil {
return fmt.Errorf("delete request by id: request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

if res.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(res.Body)
Expand All @@ -318,7 +318,7 @@ func (c *Client) DeleteRequestsByCriteria(r *Request) (*journal.DeleteRequestByC
if err != nil {
return nil, fmt.Errorf("delete requests by criteria: request error: %w", err)
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand Down Expand Up @@ -349,7 +349,7 @@ func (c *Client) DeleteStubByID(id string) error {
return fmt.Errorf("delete stub by id: request error: %w", err)
}

defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

if res.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(res.Body)
Expand Down Expand Up @@ -380,7 +380,7 @@ func (c *Client) StartRecording(targetBaseUrl string) error {
return fmt.Errorf("start recording error: %w", err)
}

defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck
if res.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand All @@ -404,7 +404,7 @@ func (c *Client) StopRecording() error {
return fmt.Errorf("stop recording error: %w", err)
}

defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck
if res.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand Down
Loading