Skip to content

Commit

Permalink
Merge pull request #107 from ArtisanCloud/develop
Browse files Browse the repository at this point in the history
refact(httpclient): open TlsConfig
  • Loading branch information
Matrix-X authored Mar 26, 2024
2 parents d795ecc + 46f76d9 commit b3e06ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion http/contract/clientInterface.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package contract

import (
"crypto/tls"
"net/http"
"time"
)
Expand All @@ -10,7 +11,7 @@ type ClientConfig struct {
Cert CertConfig
ProxyURI string
// 如果需要定制化tls, 设置该属性, 否则请使用Cert
// TlsConfig *tls.Config
TlsConfig *tls.Config
}

type CertConfig struct {
Expand All @@ -22,6 +23,7 @@ func (c *ClientConfig) Default() {
if c.Timeout == 0 {
c.Timeout = time.Second * 30
}
c.TlsConfig = &tls.Config{InsecureSkipVerify: true}
}

type ClientInterface interface {
Expand Down
18 changes: 18 additions & 0 deletions http/drivers/http/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package http

import (
"github.com/ArtisanCloud/PowerLibs/v3/http/contract"
"testing"
)

func Test_NewClient(t *testing.T) {
helper, err := NewHttpClient(&contract.ClientConfig{})
if err != nil {
t.Error(err)
}

if helper == nil {
t.Error(err)
}

}

0 comments on commit b3e06ae

Please sign in to comment.