From 86e5617d54dd6037445b97981ec7b4f37aa9afe3 Mon Sep 17 00:00:00 2001 From: Cabinfever_B Date: Thu, 23 Dec 2021 16:26:09 +0800 Subject: [PATCH] close #4490: add comment Signed-off-by: Cabinfever_B --- pkg/apiutil/apiutil.go | 5 +++-- tools/pd-ctl/pdctl/command/global.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/apiutil/apiutil.go b/pkg/apiutil/apiutil.go index 98f9491642c..28c78c2af09 100644 --- a/pkg/apiutil/apiutil.go +++ b/pkg/apiutil/apiutil.go @@ -145,13 +145,14 @@ func GetComponentNameOnHTTP(r *http.Request) string { return componentName } -type UserSignatureRoundTripper struct { +// ComponentSignatureRoundTripper is used to add component signature in HTTP header +type ComponentSignatureRoundTripper struct { Proxied http.RoundTripper Component string } // RoundTrip is used to implement RoundTripper -func (rt *UserSignatureRoundTripper) RoundTrip(req *http.Request) (resp *http.Response, err error) { +func (rt *ComponentSignatureRoundTripper) RoundTrip(req *http.Request) (resp *http.Response, err error) { req.Header.Add(ComponentSignatureKey, rt.Component) // Send the request, get the response and the error resp, err = rt.Proxied.RoundTrip(req) diff --git a/tools/pd-ctl/pdctl/command/global.go b/tools/pd-ctl/pdctl/command/global.go index 50f3021be56..a60a221a59b 100644 --- a/tools/pd-ctl/pdctl/command/global.go +++ b/tools/pd-ctl/pdctl/command/global.go @@ -31,7 +31,7 @@ import ( var ( dialClient = &http.Client{ - Transport: &apiutil.UserSignatureRoundTripper{ + Transport: &apiutil.ComponentSignatureRoundTripper{ Component: "pdctl", Proxied: http.DefaultTransport, }, @@ -52,7 +52,7 @@ func InitHTTPSClient(caPath, certPath, keyPath string) error { } dialClient = &http.Client{ - Transport: &apiutil.UserSignatureRoundTripper{ + Transport: &apiutil.ComponentSignatureRoundTripper{ Component: "pdctl", Proxied: &http.Transport{ TLSClientConfig: tlsConfig},