Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
28
pkg/superset/cache_acc_token.go
Normal file
28
pkg/superset/cache_acc_token.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package superset
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"fiskerinc.com/modules/redis"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var errTokenNotFound = errors.New("token isn't found")
|
||||
|
||||
func getCachedAccToken(c redis.Client) (string, error) {
|
||||
res, err := c.Get(redis.SupersetAccTokenKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if res == nil {
|
||||
return "", errors.WithStack(errTokenNotFound)
|
||||
}
|
||||
|
||||
tokenBytes, ok := res.([]byte)
|
||||
if !ok {
|
||||
return "", errors.WithStack(fmt.Errorf("invalid superset access token type (expected []byte]); access token: %v", res))
|
||||
}
|
||||
|
||||
return string(tokenBytes), nil
|
||||
}
|
||||
Reference in New Issue
Block a user