From a50df4fcdd6c047d1a19c04389acc862d15d47ba Mon Sep 17 00:00:00 2001 From: 0bl <141923368+0bl@users.noreply.github.com> Date: Fri, 11 Aug 2023 08:57:49 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix:=20rename=20WithTlsConfig=20?= =?UTF-8?q?method=20to=20WithTLSConfig=20(#2570)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :adhesive_bandage: Fix: rename WithTlsConfig method to WithTLSConfig * :art: Style: remove stylecheck and revive lint --- docs/api/middleware/proxy.md | 4 ++-- middleware/proxy/proxy.go | 6 ++---- middleware/proxy/proxy_test.go | 14 +++++++------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/api/middleware/proxy.md b/docs/api/middleware/proxy.md index e36654fe..aa1b5e10 100644 --- a/docs/api/middleware/proxy.md +++ b/docs/api/middleware/proxy.md @@ -42,8 +42,8 @@ After you initiate your Fiber app, you can use the following possibilities: ```go // if target https site uses a self-signed certificate, you should -// call WithTlsConfig before Do and Forward -proxy.WithTlsConfig(&tls.Config{ +// call WithTLSConfig before Do and Forward +proxy.WithTLSConfig(&tls.Config{ InsecureSkipVerify: true, }) // if you need to use global self-custom client, you should use proxy.WithClient. diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index 50987a53..284b67c8 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -105,12 +105,10 @@ var client = &fasthttp.Client{ 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. // Deprecated: use WithClient instead. -// -//nolint:stylecheck,revive // TODO: Rename to "WithTLSConfig" in v3 -func WithTlsConfig(tlsConfig *tls.Config) { +func WithTLSConfig(tlsConfig *tls.Config) { client.TLSConfig = tlsConfig } diff --git a/middleware/proxy/proxy_test.go b/middleware/proxy/proxy_test.go index 86dc2153..1ec471bd 100644 --- a/middleware/proxy/proxy_test.go +++ b/middleware/proxy/proxy_test.go @@ -104,8 +104,8 @@ func Test_Proxy(t *testing.T) { require.Equal(t, fiber.StatusTeapot, resp.StatusCode) } -// go test -run Test_Proxy_Balancer_WithTlsConfig -func Test_Proxy_Balancer_WithTlsConfig(t *testing.T) { +// go test -run Test_Proxy_Balancer_WithTLSConfig +func Test_Proxy_Balancer_WithTLSConfig(t *testing.T) { t.Parallel() serverTLSConf, _, err := tlstest.GetTLSConfigs() @@ -144,8 +144,8 @@ func Test_Proxy_Balancer_WithTlsConfig(t *testing.T) { require.Equal(t, "tls balancer", body) } -// go test -run Test_Proxy_Forward_WithTlsConfig_To_Http -func Test_Proxy_Forward_WithTlsConfig_To_Http(t *testing.T) { +// go test -run Test_Proxy_Forward_WithTLSConfig_To_Http +func Test_Proxy_Forward_WithTLSConfig_To_Http(t *testing.T) { t.Parallel() _, 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)) } -// go test -run Test_Proxy_Forward_WithTlsConfig -func Test_Proxy_Forward_WithTlsConfig(t *testing.T) { +// go test -run Test_Proxy_Forward_WithTLSConfig +func Test_Proxy_Forward_WithTLSConfig(t *testing.T) { t.Parallel() 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 // disable certificate verification - WithTlsConfig(clientTLSConf) + WithTLSConfig(clientTLSConf) app.Use(Forward("https://" + addr + "/tlsfwd")) go func() {