feat cn client支持tls
This commit is contained in:
parent
77e0c69168
commit
8ba5c95a9c
@ -2,9 +2,11 @@ package coach_client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/cloudwego/hertz/pkg/app/client"
|
||||
"github.com/cloudwego/hertz/pkg/network/standard"
|
||||
"github.com/cloudwego/hertz/pkg/protocol"
|
||||
"github.com/corpix/uarand"
|
||||
"time"
|
||||
@ -16,7 +18,13 @@ type CN struct {
|
||||
|
||||
func CNClient() (cli *CN, err error) {
|
||||
cli = new(CN)
|
||||
cli.c, err = client.NewClient()
|
||||
clientCfg := &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
cli.c, err = client.NewClient(
|
||||
client.WithTLSConfig(clientCfg),
|
||||
client.WithDialer(standard.NewDialer()),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,13 @@ func TestCNClient(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var page, total int
|
||||
var page int
|
||||
var resp ItemListData
|
||||
var items []CNItem
|
||||
for ; page <= total; page++ {
|
||||
for ; page < 2; page++ {
|
||||
if resp, err = cli.ListItems(context.Background(), page, 50); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
total = resp.TotalPages
|
||||
items = append(items, resp.Items...)
|
||||
}
|
||||
t.Logf("共%d个", len(items))
|
||||
|
Loading…
Reference in New Issue
Block a user