Skip to content
Snippets Groups Projects
Commit a8d543be authored by Kevin Lyda's avatar Kevin Lyda :speech_balloon:
Browse files

Make this work for go 1.9 and reduces code.

parent e9697230
Branches
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"net/http" "net/http"
"path"
"strings" "strings"
"github.com/nsheridan/cashier/server/auth" "github.com/nsheridan/cashier/server/auth"
...@@ -67,12 +68,8 @@ func (c *Config) newClient(token *oauth2.Token) *http.Client { ...@@ -67,12 +68,8 @@ func (c *Config) newClient(token *oauth2.Token) *http.Client {
// Gets a response for an graph api call. // Gets a response for an graph api call.
func (c *Config) getDocument(token *oauth2.Token, pathElements ...string) map[string]interface{} { func (c *Config) getDocument(token *oauth2.Token, pathElements ...string) map[string]interface{} {
client := c.newClient(token) client := c.newClient(token)
var url strings.Builder url := "https://" + path.Join("graph.microsoft.com/v1.0", path.Join(pathElements...))
url.WriteString("https://graph.microsoft.com/v1.0") resp, err := client.Get(url)
for _, pathElement := range pathElements {
url.WriteString(pathElement)
}
resp, err := client.Get(url.String())
if err != nil { if err != nil {
return nil return nil
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment