[REQ][Golang][Client] Add `*http.Client` Accessor
Created by: grokify
Is your feature request related to a problem? Please describe.
It can be useful to access the *http.Client
directly when certain APIs cannot be currently supported by OpenAPI Generator.
This is currently inaccessible in *APIClient.cfg.HTTPClient
Describe the solution you'd like
An accessor to retrieve the *http.Client
for usage.
Describe alternatives you've considered
Option 1
I currently add the following to client.go
in all my generated clients:
// HTTPClient returns the HTTP client for direct use.
func (apiClient *APIClient) HTTPClient() *http.Client {
return apiClient.cfg.HTTPClient
}
Option 2
Add a HTTPClient
accessor to APIClient
so it does not have to be first retrieved.
For example:
type APIClient struct {
cfg *Configuration
HTTPClient *http.Client // proposed
...
func NewAPIClient(cfg *Configuration) *APIClient {
if cfg.HTTPClient == nil {
cfg.HTTPClient = http.DefaultClient
}
c := &APIClient{}
c.cfg = cfg
c.HTTPClient = cfg.HTTPClient // proposed
...
Additional context
None.