You've already forked email-api-client
refactor: streamline response handling by introducing readResponseBody utility
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 22s
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 22s
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"gitea.siteworxpro.com/golang-packages/email-api-client/redis"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
@@ -53,16 +52,7 @@ func getToken(configuration *Configuration) (*Token, error) {
|
||||
return nil, errors.New("Failed to retrieve access token: " + resp.Status)
|
||||
}
|
||||
|
||||
defer func(Body io.ReadCloser) {
|
||||
_ = Body.Close()
|
||||
}(resp.Body)
|
||||
|
||||
responseBody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(responseBody, token)
|
||||
token, err = readResponseBody[Token](resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user