Skip to content

Commit

Permalink
Export go client struct CredsHeaders
Browse files Browse the repository at this point in the history
Signed-off-by: yosrixp <yosrixp@yahooinc.com>
  • Loading branch information
yosrixp committed Jan 23, 2024
1 parent 76cfc58 commit 040ac2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions clients/go/msd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = ioutil.NopCloser
type MSDClient struct {
URL string
Transport http.RoundTripper
credsHeaders map[string]string
CredsHeaders map[string]string
Timeout time.Duration
DisableRedirect bool
}
Expand All @@ -38,7 +38,7 @@ func NewClient(url string, transport http.RoundTripper) MSDClient {

// AddCredentials adds the credentials to the client for subsequent requests.
func (client *MSDClient) AddCredentials(header string, token string) {
client.credsHeaders[header] = token
client.CredsHeaders[header] = token
}

func (client MSDClient) getClient() *http.Client {
Expand All @@ -60,10 +60,10 @@ func (client MSDClient) getClient() *http.Client {
}

func (client MSDClient) addAuthHeader(req *http.Request) {
if len(client.credsHeaders) == 0 {
if len(client.CredsHeaders) == 0 {
return
}
for key, value := range client.credsHeaders {
for key, value := range client.CredsHeaders {
if strings.HasPrefix(key, "Cookie.") {
req.Header.Add("Cookie", (key)[7:]+"="+value)
} else {
Expand Down
8 changes: 4 additions & 4 deletions clients/go/zms/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = ioutil.NopCloser
type ZMSClient struct {
URL string
Transport http.RoundTripper
credsHeaders map[string]string
CredsHeaders map[string]string
Timeout time.Duration
DisableRedirect bool
}
Expand All @@ -38,7 +38,7 @@ func NewClient(url string, transport http.RoundTripper) ZMSClient {

// AddCredentials adds the credentials to the client for subsequent requests.
func (client *ZMSClient) AddCredentials(header string, token string) {
client.credsHeaders[header] = token
client.CredsHeaders[header] = token
}

func (client ZMSClient) getClient() *http.Client {
Expand All @@ -60,10 +60,10 @@ func (client ZMSClient) getClient() *http.Client {
}

func (client ZMSClient) addAuthHeader(req *http.Request) {
if len(client.credsHeaders) == 0 {
if len(client.CredsHeaders) == 0 {
return
}
for key, value := range client.credsHeaders {
for key, value := range client.CredsHeaders {
if strings.HasPrefix(key, "Cookie.") {
req.Header.Add("Cookie", (key)[7:]+"="+value)
} else {
Expand Down
8 changes: 4 additions & 4 deletions clients/go/zts/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = ioutil.NopCloser
type ZTSClient struct {
URL string
Transport http.RoundTripper
credsHeaders map[string]string
CredsHeaders map[string]string
Timeout time.Duration
DisableRedirect bool
}
Expand All @@ -38,7 +38,7 @@ func NewClient(url string, transport http.RoundTripper) ZTSClient {

// AddCredentials adds the credentials to the client for subsequent requests.
func (client *ZTSClient) AddCredentials(header string, token string) {
client.credsHeaders[header] = token
client.CredsHeaders[header] = token
}

func (client ZTSClient) getClient() *http.Client {
Expand All @@ -60,10 +60,10 @@ func (client ZTSClient) getClient() *http.Client {
}

func (client ZTSClient) addAuthHeader(req *http.Request) {
if len(client.credsHeaders) == 0 {
if len(client.CredsHeaders) == 0 {
return
}
for key, value := range client.credsHeaders {
for key, value := range client.CredsHeaders {
if strings.HasPrefix(key, "Cookie.") {
req.Header.Add("Cookie", (key)[7:]+"="+value)
} else {
Expand Down
8 changes: 4 additions & 4 deletions rdl/rdl-gen-athenz-go-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var _ = ioutil.NopCloser
type {{client}} struct {
URL string
Transport http.RoundTripper
credsHeaders map[string]string
CredsHeaders map[string]string
Timeout time.Duration
DisableRedirect bool
}
Expand All @@ -128,7 +128,7 @@ func NewClient(url string, transport http.RoundTripper) {{client}} {
// AddCredentials adds the credentials to the client for subsequent requests.
func (client *{{client}}) AddCredentials(header string, token string) {
client.credsHeaders[header] = token
client.CredsHeaders[header] = token
}
func (client {{client}}) getClient() *http.Client {
Expand All @@ -150,10 +150,10 @@ func (client {{client}}) getClient() *http.Client {
}
func (client {{client}}) addAuthHeader(req *http.Request) {
if len(client.credsHeaders) == 0 {
if len(client.CredsHeaders) == 0 {
return
}
for key, value := range client.credsHeaders {
for key, value := range client.CredsHeaders {
if strings.HasPrefix(key, "Cookie.") {
req.Header.Add("Cookie", (key)[7:]+"="+value)
} else {
Expand Down

0 comments on commit 040ac2a

Please sign in to comment.