Dane caused this monstrosity to occur.. Port over remaining transfer/archive code to gin, delete http.go

This commit is contained in:
Matthew Penner
2020-04-06 13:49:49 -06:00
parent 03311ecf03
commit 718b126baf
7 changed files with 106 additions and 167 deletions

View File

@@ -1,25 +1,25 @@
package tokens
import (
cache2 "github.com/patrickmn/go-cache"
"github.com/patrickmn/go-cache"
"sync"
"time"
)
type TokenStore struct {
cache *cache2.Cache
cache *cache.Cache
mutex *sync.Mutex
}
var _tokens *TokenStore
// Returns the global unqiue token store cache. This is used to validate
// Returns the global unique token store cache. This is used to validate
// one time token usage by storing any received tokens in a local memory
// cache until they are ready to expire.
func getTokenStore() *TokenStore {
if _tokens == nil {
_tokens = &TokenStore{
cache: cache2.New(time.Minute*60, time.Minute*5),
cache: cache.New(time.Minute*60, time.Minute*5),
mutex: &sync.Mutex{},
}
}

14
router/tokens/transfer.go Normal file
View File

@@ -0,0 +1,14 @@
package tokens
import (
"github.com/gbrlsnchs/jwt/v3"
)
type TransferPayload struct {
jwt.Payload
}
// GetPayload returns the JWT payload.
func (p *TransferPayload) GetPayload() *jwt.Payload {
return &p.Payload
}