-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
33 lines (27 loc) · 812 Bytes
/
client.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
32
33
package tron
import (
"time"
"github.com/fbsobreira/gotron-sdk/pkg/client"
"github.com/go-resty/resty/v2"
"google.golang.org/grpc"
)
func NewGrpcClient(endpoint string) (c *client.GrpcClient, err error) {
c = client.NewGrpcClient(endpoint)
err = c.Start(grpc.WithInsecure())
return
}
func NewHttpClient(endpoint string) (c *resty.Client) {
headers := map[string]string{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
"accept": "application/json",
}
c = resty.New().
SetRetryCount(3).
SetRetryWaitTime(time.Second).
SetBaseURL(endpoint).
SetHeaders(headers)
return
}
func SetHttpClientApiKey(client *resty.Client, key string) (c *resty.Client) {
return client.SetHeader("TRON-PRO-API-KEY", key)
}