Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuomo Ala-Vannesluoma <tuomoav@gmail.com>2018-06-18 20:21:11 +0300
committerTuomo Ala-Vannesluoma <tuomoav@gmail.com>2018-06-30 22:51:43 +0300
commitc3dc6f13f26ca57862afc9a7e1be6d4392021f87 (patch)
tree298b9962695cb566f34de8bec48d1f11cf63f2d4 /internal/auth
parent1b2c9bec53272e1f757015dcb28c835492b25ad0 (diff)
Use json decoder directly
Diffstat (limited to 'internal/auth')
-rw-r--r--internal/auth/auth.go9
1 files changed, 2 insertions, 7 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go
index 407de0c3..0278dcbe 100644
--- a/internal/auth/auth.go
+++ b/internal/auth/auth.go
@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
- "io/ioutil"
"net/http"
"strings"
"time"
@@ -172,10 +171,8 @@ func (a *Auth) fetchAccessToken(code string) (tokenResponse, error) {
}
// Parse response
- body, _ := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
-
- err = json.Unmarshal(body, &token)
+ err = json.NewDecoder(resp.Body).Decode(&token)
if err != nil {
return token, err
}
@@ -249,10 +246,8 @@ func checkResponseForInvalidToken(resp *http.Response, err error) bool {
errResp := errorResponse{}
// Parse response
- body, _ := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
-
- err = json.Unmarshal(body, &errResp)
+ err := json.NewDecoder(resp.Body).Decode(&errResp)
if err != nil {
return false
}