File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
internals/proxy/middlewares Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,18 @@ type contextKey string
2323
2424const 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}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ func LoadTokens() {
2424func InitTokens () {
2525 apiTokens := config .Strings ("api.tokens" )
2626
27- var tokenConfigs []TOKEN_CONFIG_
27+ tokenConfigs := []TOKEN_CONFIG_ {}
2828
2929 tokensLayer .Unmarshal ("tokenConfigs" , & tokenConfigs )
3030
You can’t perform that action at this time.
0 commit comments