Merge pull request #242 from github/debug-api

Dump HTTP request/response bodies when `DEBUG=api`
This commit is contained in:
Nate Smith 2020-01-22 14:05:29 -06:00 committed by GitHub
commit 340f747944
2 changed files with 24 additions and 3 deletions

View file

@ -84,7 +84,7 @@ func BasicClient() (*api.Client, error) {
opts = append(opts, api.AddHeader("Authorization", fmt.Sprintf("token %s", c.Token)))
}
if verbose := os.Getenv("DEBUG"); verbose != "" {
opts = append(opts, api.VerboseLog(os.Stderr))
opts = append(opts, api.VerboseLog(os.Stderr, false))
}
return api.NewClient(opts...), nil
}
@ -113,7 +113,7 @@ var apiClientForContext = func(ctx context.Context) (*api.Client, error) {
api.AddHeader("GraphQL-Features", "pe_mobile"),
}
if verbose := os.Getenv("DEBUG"); verbose != "" {
opts = append(opts, api.VerboseLog(os.Stderr))
opts = append(opts, api.VerboseLog(os.Stderr, strings.Contains(verbose, "api")))
}
return api.NewClient(opts...), nil
}