summaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/internal/endpoints/endpoints.go
blob: 12e4fb529a77db31a13e2d5588ba2963454983cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package endpoints

//go:generate go run ../model/cli/gen-endpoints/main.go endpoints.json endpoints_map.go

import "strings"

func EndpointForRegion(svcName, region string) string {
	derivedKeys := []string{
		region + "/" + svcName,
		region + "/*",
		"*/" + svcName,
		"*/*",
	}

	for _, key := range derivedKeys {
		if val, ok := endpointsMap.Endpoints[key]; ok {
			ep := val.Endpoint
			ep = strings.Replace(ep, "{region}", region, -1)
			ep = strings.Replace(ep, "{service}", svcName, -1)
			return ep
		}
	}
	return ""
}