Skip to content

Commit

Permalink
close tikv#4490: add comment
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
  • Loading branch information
CabinfeverB committed Dec 28, 2021
1 parent a4fb71a commit 86e5617
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/apiutil/apiutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tools/pd-ctl/pdctl/command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

var (
dialClient = &http.Client{
Transport: &apiutil.UserSignatureRoundTripper{
Transport: &apiutil.ComponentSignatureRoundTripper{
Component: "pdctl",
Proxied: http.DefaultTransport,
},
Expand All @@ -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},
Expand Down

0 comments on commit 86e5617

Please sign in to comment.