Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
RMPall committed Feb 16, 2022
1 parent b601ba8 commit cfd4908
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 12 additions & 3 deletions http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"time"

request "github.com/ONSdigital/dp-net/request"
"github.com/ONSdigital/dp-net/request"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
)
Expand Down Expand Up @@ -68,8 +68,16 @@ type Clienter interface {

// NewClient returns a copy of DefaultClient.
func NewClient() Clienter {
newClient := *DefaultClient
return &newClient
newClient := &Client{
MaxRetries: 3,
RetryTime: 20 * time.Millisecond,

HTTPClient: &http.Client{
Timeout: 10 * time.Second,
Transport: DefaultTransport,
},
}
return newClient
}

// NewClientWithAwsSigner return a new client with aws signer profile.
Expand All @@ -94,6 +102,7 @@ func ClientWithTimeout(c Clienter, timeout time.Duration) Clienter {

// Clienter roundtripper calls the httpclient roundtripper.
func (c *Client) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Set("test", "001")
return c.HTTPClient.Transport.RoundTrip(req)
}

Expand Down
7 changes: 4 additions & 3 deletions http/custom_roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package http
import (
"bytes"
"fmt"
awsAuth "github.com/ONSdigital/dp-net/awsauth"
"io"
"net/http"
"time"

awsAuth "github.com/ONSdigital/dp-net/awsauth"
)

type AwsSignerRoundTripper struct {
Expand All @@ -16,6 +15,7 @@ type AwsSignerRoundTripper struct {
}

func NewAWSSignerRoundTripper(awsFilename, awsProfile, awsRegion, awsService string, customTransport http.RoundTripper) (*AwsSignerRoundTripper, error) {
fmt.Println("inside aws signer..........................")
var roundTripper http.RoundTripper
if awsRegion == "" || awsService == "" {
return nil, fmt.Errorf("aws region and service should be valid options")
Expand All @@ -32,12 +32,13 @@ func NewAWSSignerRoundTripper(awsFilename, awsProfile, awsRegion, awsService str
}

return &AwsSignerRoundTripper{
signer: awsSigner,
roundTripper: roundTripper,
signer: awsSigner,
}, nil
}

func (srt *AwsSignerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
fmt.Println("inside round tripper..........................")
var body []byte
var err error
if req.Body != nil {
Expand Down

0 comments on commit cfd4908

Please sign in to comment.