🩹 Fix: rename WithTlsConfig method to WithTLSConfig (#2570)

* 🩹 Fix: rename WithTlsConfig method to WithTLSConfig

* 🎨 Style: remove stylecheck and revive lint
pull/2764/head
0bl 2023-08-11 08:57:49 +03:00 committed by GitHub
parent 44acb06c02
commit a50df4fcdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 13 deletions

View File

@ -42,8 +42,8 @@ After you initiate your Fiber app, you can use the following possibilities:
```go ```go
// if target https site uses a self-signed certificate, you should // if target https site uses a self-signed certificate, you should
// call WithTlsConfig before Do and Forward // call WithTLSConfig before Do and Forward
proxy.WithTlsConfig(&tls.Config{ proxy.WithTLSConfig(&tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
}) })
// if you need to use global self-custom client, you should use proxy.WithClient. // if you need to use global self-custom client, you should use proxy.WithClient.

View File

@ -105,12 +105,10 @@ var client = &fasthttp.Client{
var lock sync.RWMutex var lock sync.RWMutex
// WithTlsConfig update http client with a user specified tls.config // WithTLSConfig update http client with a user specified tls.config
// This function should be called before Do and Forward. // This function should be called before Do and Forward.
// Deprecated: use WithClient instead. // Deprecated: use WithClient instead.
// func WithTLSConfig(tlsConfig *tls.Config) {
//nolint:stylecheck,revive // TODO: Rename to "WithTLSConfig" in v3
func WithTlsConfig(tlsConfig *tls.Config) {
client.TLSConfig = tlsConfig client.TLSConfig = tlsConfig
} }

View File

@ -104,8 +104,8 @@ func Test_Proxy(t *testing.T) {
require.Equal(t, fiber.StatusTeapot, resp.StatusCode) require.Equal(t, fiber.StatusTeapot, resp.StatusCode)
} }
// go test -run Test_Proxy_Balancer_WithTlsConfig // go test -run Test_Proxy_Balancer_WithTLSConfig
func Test_Proxy_Balancer_WithTlsConfig(t *testing.T) { func Test_Proxy_Balancer_WithTLSConfig(t *testing.T) {
t.Parallel() t.Parallel()
serverTLSConf, _, err := tlstest.GetTLSConfigs() serverTLSConf, _, err := tlstest.GetTLSConfigs()
@ -144,8 +144,8 @@ func Test_Proxy_Balancer_WithTlsConfig(t *testing.T) {
require.Equal(t, "tls balancer", body) require.Equal(t, "tls balancer", body)
} }
// go test -run Test_Proxy_Forward_WithTlsConfig_To_Http // go test -run Test_Proxy_Forward_WithTLSConfig_To_Http
func Test_Proxy_Forward_WithTlsConfig_To_Http(t *testing.T) { func Test_Proxy_Forward_WithTLSConfig_To_Http(t *testing.T) {
t.Parallel() t.Parallel()
_, targetAddr := createProxyTestServer(t, func(c fiber.Ctx) error { _, targetAddr := createProxyTestServer(t, func(c fiber.Ctx) error {
@ -203,8 +203,8 @@ func Test_Proxy_Forward(t *testing.T) {
require.Equal(t, "forwarded", string(b)) require.Equal(t, "forwarded", string(b))
} }
// go test -run Test_Proxy_Forward_WithTlsConfig // go test -run Test_Proxy_Forward_WithTLSConfig
func Test_Proxy_Forward_WithTlsConfig(t *testing.T) { func Test_Proxy_Forward_WithTLSConfig(t *testing.T) {
t.Parallel() t.Parallel()
serverTLSConf, _, err := tlstest.GetTLSConfigs() serverTLSConf, _, err := tlstest.GetTLSConfigs()
@ -225,7 +225,7 @@ func Test_Proxy_Forward_WithTlsConfig(t *testing.T) {
clientTLSConf := &tls.Config{InsecureSkipVerify: true} //nolint:gosec // We're in a test func, so this is fine clientTLSConf := &tls.Config{InsecureSkipVerify: true} //nolint:gosec // We're in a test func, so this is fine
// disable certificate verification // disable certificate verification
WithTlsConfig(clientTLSConf) WithTLSConfig(clientTLSConf)
app.Use(Forward("https://" + addr + "/tlsfwd")) app.Use(Forward("https://" + addr + "/tlsfwd"))
go func() { go func() {