NewClient returns a new CF Networking client.
(config Config)
| 115 | |
| 116 | // NewClient returns a new CF Networking client. |
| 117 | func NewClient(config Config) *Client { |
| 118 | userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS) |
| 119 | |
| 120 | connection := cfnetworking.NewConnection(cfnetworking.Config{ |
| 121 | DialTimeout: config.DialTimeout, |
| 122 | SkipSSLValidation: config.SkipSSLValidation, |
| 123 | }) |
| 124 | |
| 125 | wrappedConnection := cfnetworking.NewErrorWrapper().Wrap(connection) |
| 126 | for _, wrapper := range config.Wrappers { |
| 127 | wrappedConnection = wrapper.Wrap(wrappedConnection) |
| 128 | } |
| 129 | |
| 130 | client := &Client{ |
| 131 | connection: wrappedConnection, |
| 132 | router: rata.NewRequestGenerator(config.URL, internal.Routes), |
| 133 | url: config.URL, |
| 134 | userAgent: userAgent, |
| 135 | } |
| 136 | |
| 137 | return client |
| 138 | } |