NewClient returns a new Router Client.
(config Config)
| 38 | |
| 39 | // NewClient returns a new Router Client. |
| 40 | func NewClient(config Config) *Client { |
| 41 | userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", |
| 42 | config.AppName, |
| 43 | config.AppVersion, |
| 44 | runtime.Version(), |
| 45 | runtime.GOARCH, |
| 46 | runtime.GOOS, |
| 47 | ) |
| 48 | |
| 49 | client := Client{ |
| 50 | userAgent: userAgent, |
| 51 | router: rata.NewRequestGenerator(config.RoutingEndpoint, internal.APIRoutes), |
| 52 | connection: NewConnection(config.ConnectionConfig), |
| 53 | } |
| 54 | |
| 55 | for _, wrapper := range config.Wrappers { |
| 56 | client.connection = wrapper.Wrap(client.connection) |
| 57 | } |
| 58 | |
| 59 | return &client |
| 60 | } |