Skip to content

Commit

Permalink
Renamed repo, added go modules, protect access token from concurrent …
Browse files Browse the repository at this point in the history
…read access.
  • Loading branch information
Kugelschieber committed Dec 4, 2020
1 parent 0787cab commit 66a76ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Client struct {
hostname string
accessToken string
expiresAt time.Time
m sync.Mutex
m sync.RWMutex
}

// ClientConfig is used to configure the Client.
Expand Down Expand Up @@ -152,5 +152,7 @@ func (client *Client) performPost(url string, body interface{}) error {
}

func (client *Client) setRequestHeaders(req *http.Request) {
client.m.RLock()
defer client.m.RUnlock()
req.Header.Set("Authorization", "Bearer "+client.accessToken)
}
2 changes: 1 addition & 1 deletion demo/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/pirsch-analytics/go-sdk"
"github.com/pirsch-analytics/pirsch-go-sdk"
"log"
"net/http"
)
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/pirsch-analytics/pirsch-go-sdk

go 1.15

0 comments on commit 66a76ed

Please sign in to comment.