mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 11:47:42 +00:00
only get parser when we actually need it
This commit is contained in:
parent
9e77a662a3
commit
56d72d5dea
1 changed files with 6 additions and 3 deletions
|
@ -122,13 +122,13 @@ func (rac *AuthenticatedClient) request(r *Request, rh ResponseHandler, empty in
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
parser := rac.pool.Get()
|
|
||||||
defer rac.pool.Put(parser)
|
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
rac.statsd.Incr("reddit.api.errors", r.tags, 0.1)
|
rac.statsd.Incr("reddit.api.errors", r.tags, 0.1)
|
||||||
|
|
||||||
// Try to parse a json error. Otherwise we generate a generic one
|
// Try to parse a json error. Otherwise we generate a generic one
|
||||||
|
parser := rac.pool.Get()
|
||||||
|
defer rac.pool.Put(parser)
|
||||||
|
|
||||||
val, jerr := parser.ParseBytes(bb)
|
val, jerr := parser.ParseBytes(bb)
|
||||||
if jerr != nil {
|
if jerr != nil {
|
||||||
return nil, fmt.Errorf("error from reddit: %d", resp.StatusCode)
|
return nil, fmt.Errorf("error from reddit: %d", resp.StatusCode)
|
||||||
|
@ -140,6 +140,9 @@ func (rac *AuthenticatedClient) request(r *Request, rh ResponseHandler, empty in
|
||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parser := rac.pool.Get()
|
||||||
|
defer rac.pool.Put(parser)
|
||||||
|
|
||||||
val, err := parser.ParseBytes(bb)
|
val, err := parser.ParseBytes(bb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue