Skip to content

Commit

Permalink
fix github deprecation msg
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewedy committed Aug 29, 2020
1 parent 6ba3f6d commit 462c1f1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions config/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ func updateFile(filename string, fn func(filename string) gist) {
return
}

req, err := http.NewRequest(http.MethodPatch, gistApiUrl+"?access_token="+token(), buf)
req, err := http.NewRequest(http.MethodPatch, gistApiUrl, buf)
if err != nil {
return
}
req.Header.Set("Accept", "application/vnd.github.v3+json")

setHeaders(req)

client := &http.Client{}
resp, err := client.Do(req)
Expand All @@ -86,8 +87,7 @@ func getContent(filename string) string {
if err != nil {
return ""
}
req.Header.Set("Accept", "application/vnd.github.v3+json")
req.Header.Set("Authorization", token())
setHeaders(req)

client := &http.Client{}
resp, err := client.Do(req)
Expand All @@ -105,6 +105,11 @@ func getContent(filename string) string {
return g.Files[filename].Content
}

func setHeaders(req *http.Request) {
req.Header.Set("Accept", "application/vnd.github.v3+json")
req.Header.Set("Authorization", "token "+token())
}

func errorAsString(err error) string {
var errStr string
if err != nil {
Expand Down

0 comments on commit 462c1f1

Please sign in to comment.