Skip to content

Commit

Permalink
change verb of http func
Browse files Browse the repository at this point in the history
  • Loading branch information
billiford committed Sep 7, 2020
1 parent e2f16ad commit 55dc4e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/arcade/arcade.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func init() {
r.Use(gin.Recovery())
r.Use(middleware.NewApiKeyAuth(apiKey))

r.GET("/tokens", http.NewToken)
r.GET("/tokens", http.GetToken)
}

// Run arcade on port 1982.
Expand Down
14 changes: 7 additions & 7 deletions pkg/http/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import (
)

var (
mux sync.Mutex
t time.Time
token string
err error
duration = time.Duration(1 * time.Minute)
mux sync.Mutex
t time.Time
token string
err error
expiration = 1 * time.Minute
)

func NewToken(c *gin.Context) {
func GetToken(c *gin.Context) {
mux.Lock()
defer mux.Unlock()

if time.Since(t) > duration || token == "" {
if time.Since(t) > expiration || token == "" {
token, err = google.NewToken()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
Expand Down

0 comments on commit 55dc4e8

Please sign in to comment.