Skip to content

Commit

Permalink
refactor: inherit value from client enables clean request overrides #516
Browse files Browse the repository at this point in the history
 (#706)
  • Loading branch information
jeevatkm committed Sep 24, 2023
1 parent 0424ad1 commit ab02f20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions client.go
Expand Up @@ -433,17 +433,18 @@ func (c *Client) SetDigestAuth(username, password string) *Client {
// R method creates a new request instance, its used for Get, Post, Put, Delete, Patch, Head, Options, etc.
func (c *Client) R() *Request {
r := &Request{
QueryParam: url.Values{},
FormData: url.Values{},
Header: http.Header{},
Cookies: make([]*http.Cookie, 0),
QueryParam: url.Values{},
FormData: url.Values{},
Header: http.Header{},
Cookies: make([]*http.Cookie, 0),
PathParams: map[string]string{},
RawPathParams: map[string]string{},
Debug: c.Debug,

client: c,
multipartFiles: []*File{},
multipartFields: []*MultipartField{},
PathParams: map[string]string{},
RawPathParams: map[string]string{},
jsonEscapeHTML: true,
jsonEscapeHTML: c.jsonEscapeHTML,
log: c.log,
}
return r
Expand Down
4 changes: 2 additions & 2 deletions middleware.go
Expand Up @@ -277,7 +277,7 @@ func addCredentials(c *Client, r *Request) error {
}

func requestLogger(c *Client, r *Request) error {
if c.Debug || r.Debug {
if r.Debug {
rr := r.RawRequest
rl := &RequestLog{Header: copyHeaders(rr.Header), Body: r.fmtBodyString(c.debugBodySizeLimit)}
if c.requestLog != nil {
Expand Down Expand Up @@ -307,7 +307,7 @@ func requestLogger(c *Client, r *Request) error {
//_______________________________________________________________________

func responseLogger(c *Client, res *Response) error {
if c.Debug || res.Request.Debug {
if res.Request.Debug {
rl := &ResponseLog{Header: copyHeaders(res.Header()), Body: res.fmtBodyString(c.debugBodySizeLimit)}
if c.responseLog != nil {
if err := c.responseLog(rl); err != nil {
Expand Down

0 comments on commit ab02f20

Please sign in to comment.