28 lines
715 B
Go
28 lines
715 B
Go
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)
|
|
}
|