mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
change https bool to scheme string
This commit is contained in:
4
etcd.go
4
etcd.go
@@ -268,7 +268,7 @@ func createTransporter(st int) transporter {
|
||||
|
||||
switch st {
|
||||
case HTTP:
|
||||
t.https = false
|
||||
t.scheme = "http://"
|
||||
|
||||
tr := &http.Transport{
|
||||
Dial: dialTimeout,
|
||||
@@ -282,7 +282,7 @@ func createTransporter(st int) transporter {
|
||||
case HTTPS:
|
||||
fallthrough
|
||||
case HTTPSANDVERIFY:
|
||||
t.https = true
|
||||
t.scheme = "https://"
|
||||
|
||||
tlsCert, err := tls.LoadX509KeyPair(serverCertFile, serverKeyFile)
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
// Transporter layer for communication between raft nodes
|
||||
type transporter struct {
|
||||
client *http.Client
|
||||
// https
|
||||
https bool
|
||||
// scheme
|
||||
scheme string
|
||||
}
|
||||
|
||||
// Sends AppendEntries RPCs to a peer when the server is the leader.
|
||||
@@ -102,23 +102,12 @@ func (t transporter) GetLeaderClientAddress() string {
|
||||
|
||||
// Send server side POST request
|
||||
func (t transporter) Post(path string, body io.Reader) (*http.Response, error) {
|
||||
|
||||
if t.https {
|
||||
resp, err := t.client.Post("https://"+path, "application/json", body)
|
||||
resp, err := t.client.Post(t.scheme + path, "application/json", body)
|
||||
return resp, err
|
||||
} else {
|
||||
resp, err := t.client.Post("http://"+path, "application/json", body)
|
||||
return resp, err
|
||||
}
|
||||
}
|
||||
|
||||
// Send server side GET request
|
||||
func (t transporter) Get(path string) (*http.Response, error) {
|
||||
if t.https {
|
||||
resp, err := t.client.Get("https://" + path)
|
||||
resp, err := t.client.Get(t.scheme + path)
|
||||
return resp, err
|
||||
} else {
|
||||
resp, err := t.client.Get("http://" + path)
|
||||
return resp, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user