Skip to content

Commit

Permalink
feat(tg): accept any http client what satisfies doer interface (#120)
Browse files Browse the repository at this point in the history
* feat(tg): accept any http client what satisfies doer interface

This will makes possible usage of github.com/hashicorp/go-retryablehttp, any any http client which relies on some internal things  and have different from http.Client struct return, but satisfies http interface

* feat: make doer interface public
  • Loading branch information
Satont authored Apr 10, 2023
1 parent 0acfbe9 commit 2d3a2e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
)

type doer interface {
type Doer interface {
Do(r *http.Request) (*http.Response, error)
}

Expand All @@ -30,7 +30,7 @@ type Client struct {

// http client,
// default values is http.DefaultClient
doer doer
doer Doer

// contains cached bot info
me *User
Expand All @@ -48,7 +48,7 @@ func WithClientServerURL(server string) ClientOption {
}

// WithClientDoer sets custom http client for Client.
func WithClientDoer(doer *http.Client) ClientOption {
func WithClientDoer(doer Doer) ClientOption {
return func(c *Client) {
c.doer = doer
}
Expand Down

0 comments on commit 2d3a2e6

Please sign in to comment.