NewClient returns a new Client. It is safe to use the returned Client from multiple goroutines.
(cfg Config)
| 87 | // |
| 88 | // It is safe to use the returned Client from multiple goroutines. |
| 89 | func NewClient(cfg Config) (Client, error) { |
| 90 | u, err := url.Parse(cfg.Address) |
| 91 | if err != nil { |
| 92 | return nil, err |
| 93 | } |
| 94 | u.Path = strings.TrimRight(u.Path, "/") |
| 95 | |
| 96 | if err := cfg.validate(); err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | |
| 100 | return &httpClient{ |
| 101 | endpoint: u, |
| 102 | client: cfg.client(), |
| 103 | }, nil |
| 104 | } |
| 105 | |
| 106 | type httpClient struct { |
| 107 | endpoint *url.URL |