Fixes + stable gateway ids
This commit is contained in:
27
api/pkg/discovery/gatewayid.go
Normal file
27
api/pkg/discovery/gatewayid.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package discovery
|
||||
|
||||
import "strings"
|
||||
|
||||
// StableGatewayID composes a stable discovery entry ID from a base prefix and key.
|
||||
func StableGatewayID(prefix string, key string) string {
|
||||
cleanPrefix := strings.ToLower(strings.TrimSpace(prefix))
|
||||
cleanKey := strings.ToLower(strings.TrimSpace(key))
|
||||
if cleanKey == "" {
|
||||
cleanKey = "unknown"
|
||||
}
|
||||
if cleanPrefix == "" {
|
||||
return cleanKey
|
||||
}
|
||||
if strings.HasSuffix(cleanPrefix, "_") {
|
||||
return cleanPrefix + cleanKey
|
||||
}
|
||||
return cleanPrefix + "_" + cleanKey
|
||||
}
|
||||
|
||||
func StableCryptoRailGatewayID(network string) string {
|
||||
return StableGatewayID("crypto_rail_gateway", network)
|
||||
}
|
||||
|
||||
func StablePaymentGatewayID(rail string) string {
|
||||
return StableGatewayID("payment_gateway", rail)
|
||||
}
|
||||
Reference in New Issue
Block a user