Skip to content

Commit b32cbc2

Browse files
committed
testing
1 parent 397e4ad commit b32cbc2

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

internals/proxy/middlewares/common.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ type contextKey string
2323

2424
const tokenKey contextKey = "token"
2525

26-
func getSettings(req *http.Request) config.SETTING_ {
27-
token := req.Context().Value(tokenKey).(string)
26+
func getSettings(req *http.Request) *config.SETTING_ {
27+
token, ok := req.Context().Value(tokenKey).(string)
2828

29-
settings := config.ENV.SETTINGS[token]
29+
if !ok {
30+
token = "*"
31+
}
3032

31-
if settings == nil {
32-
settings = config.ENV.SETTINGS["*"]
33-
}
33+
settings, exists := config.ENV.SETTINGS[token]
3434

35-
return *settings
35+
if !exists || settings == nil {
36+
settings = config.ENV.SETTINGS["*"]
37+
}
38+
39+
return settings
3640
}

utils/config/token-config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func LoadTokens() {
2424
func InitTokens() {
2525
apiTokens := config.Strings("api.tokens")
2626

27-
var tokenConfigs []TOKEN_CONFIG_
27+
tokenConfigs := []TOKEN_CONFIG_{}
2828

2929
tokensLayer.Unmarshal("tokenConfigs", &tokenConfigs)
3030

0 commit comments

Comments
 (0)