Skip to content

Commit

Permalink
Copy a new client inside WithRespHandler
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Nov 21, 2023
1 parent d9e988c commit fe929aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ func (c *client) Close() {
log.Info("[pd] http client closed")
}

// WithRespHandler sets the client with the given HTTP response handler.
// WithRespHandler sets and returns a new client with the given HTTP response handler.
// This allows the caller to customize how the response is handled, including error handling logic.
func (c *client) WithRespHandler(handler func(resp *http.Response) error) Client {
c.respHandler = handler
newClient := *c
newClient.respHandler = handler
return c
}

Expand Down

0 comments on commit fe929aa

Please sign in to comment.