Skip to content

Commit

Permalink
regenerate golden-files/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Mar 28, 2017
1 parent b0b1dc5 commit eb3e93b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 82 deletions.
41 changes: 18 additions & 23 deletions codegen/test_data/clients/bar.gogen
Expand Up @@ -13,31 +13,28 @@ import (
)

// BarClient is the http client for service Bar.
type BarClient zanzibar.HTTPClient
type BarClient struct {
client *zanzibar.HTTPClient
}

// NewClient returns a new http client for service Bar.
func NewClient(config *zanzibar.StaticConfig) *BarClient {
func NewClient(
config *zanzibar.StaticConfig,
gateway *zanzibar.Gateway,
) *BarClient {
ip := config.MustGetString("clients.bar.ip")
port := config.MustGetInt("clients.bar.port")

baseURL := "http://" + ip + ":" + strconv.Itoa(int(port))
return &BarClient{
Client: &http.Client{
Transport: &http.Transport{
DisableKeepAlives: false,
MaxIdleConns: 500,
MaxIdleConnsPerHost: 500,
},
},
BaseURL: baseURL,
client: zanzibar.NewHTTPClient(gateway, baseURL),
}
}

// ArgNotStruct calls "/arg-not-struct-path" endpoint.
func (c *BarClient) ArgNotStruct(ctx context.Context, r *ArgNotStructHTTPRequest) (*http.Response, error) {
// Generate full URL.
// TODO: (jakev) insert params if needed here.
fullURL := c.BaseURL + "/arg-not-struct-path"
fullURL := c.client.BaseURL + "/arg-not-struct-path"

rawBody, err := r.MarshalJSON()
if err != nil {
Expand All @@ -49,40 +46,39 @@ func (c *BarClient) ArgNotStruct(ctx context.Context, r *ArgNotStructHTTPRequest
return nil, err
}
req.Header.Set("Content-Type", "application/json")
return c.Client.Do(req.WithContext(ctx))
return c.client.Client.Do(req.WithContext(ctx))
}

// MissingArg calls "/missing-arg-path" endpoint.
func (c *BarClient) MissingArg(ctx context.Context) (*http.Response, error) {
// Generate full URL.
fullURL := c.BaseURL + "/missing-arg-path"
fullURL := c.client.BaseURL + "/missing-arg-path"

req, err := http.NewRequest("GET", fullURL, nil)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
return c.Client.Do(req.WithContext(ctx))
return c.client.Client.Do(req.WithContext(ctx))
}

// NoRequest calls "/no-request-path" endpoint.
func (c *BarClient) NoRequest(ctx context.Context) (*http.Response, error) {
// Generate full URL.
fullURL := c.BaseURL + "/no-request-path"
fullURL := c.client.BaseURL + "/no-request-path"

req, err := http.NewRequest("GET", fullURL, nil)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
return c.Client.Do(req.WithContext(ctx))
return c.client.Client.Do(req.WithContext(ctx))
}

// Normal calls "/bar-path" endpoint.
func (c *BarClient) Normal(ctx context.Context, r *NormalHTTPRequest) (*http.Response, error) {
// Generate full URL.
// TODO: (jakev) insert params if needed here.
fullURL := c.BaseURL + "/bar-path"
fullURL := c.client.BaseURL + "/bar-path"

rawBody, err := r.MarshalJSON()
if err != nil {
Expand All @@ -94,14 +90,13 @@ func (c *BarClient) Normal(ctx context.Context, r *NormalHTTPRequest) (*http.Res
return nil, err
}
req.Header.Set("Content-Type", "application/json")
return c.Client.Do(req.WithContext(ctx))
return c.client.Client.Do(req.WithContext(ctx))
}

// TooManyArgs calls "/too-many-args-path" endpoint.
func (c *BarClient) TooManyArgs(ctx context.Context, r *TooManyArgsHTTPRequest) (*http.Response, error) {
// Generate full URL.
// TODO: (jakev) insert params if needed here.
fullURL := c.BaseURL + "/too-many-args-path"
fullURL := c.client.BaseURL + "/too-many-args-path"

rawBody, err := r.MarshalJSON()
if err != nil {
Expand All @@ -113,5 +108,5 @@ func (c *BarClient) TooManyArgs(ctx context.Context, r *TooManyArgsHTTPRequest)
return nil, err
}
req.Header.Set("Content-Type", "application/json")
return c.Client.Do(req.WithContext(ctx))
return c.client.Client.Do(req.WithContext(ctx))
}
41 changes: 18 additions & 23 deletions examples/example-gateway/build/clients/bar/bar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions examples/example-gateway/build/clients/clients.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions examples/example-gateway/build/clients/contacts/contacts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions examples/example-gateway/build/clients/googlenow/googlenow.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions examples/example-gateway/build/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eb3e93b

Please sign in to comment.