-
Notifications
You must be signed in to change notification settings - Fork 5
/
platformclientfactory.go
31 lines (27 loc) · 1.04 KB
/
platformclientfactory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2021 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
package factory
import (
"github.com/AccelByte/accelbyte-go-sdk/platform-sdk/pkg/platformclient"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository"
"strings"
)
var platformClientInstance *platformclient.JusticePlatformService
func NewPlatformClient(configRepository repository.ConfigRepository) *platformclient.JusticePlatformService {
if platformClientInstance == nil {
baseUrl := configRepository.GetJusticeBaseUrl()
if len(baseUrl) > 0 {
baseUrlSplit := strings.Split(baseUrl, "://")
httpClientConfig := &platformclient.TransportConfig{
Host: baseUrlSplit[1],
BasePath: "/platform",
Schemes: []string{baseUrlSplit[0]},
}
platformClientInstance = platformclient.NewHTTPClientWithConfig(nil, httpClientConfig)
} else {
platformClientInstance = platformclient.NewHTTPClient(nil)
}
}
return platformClientInstance
}