mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +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
|
||||
}
|
||||
|
||||
parser := rac.pool.Get()
|
||||
defer rac.pool.Put(parser)
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
rac.statsd.Incr("reddit.api.errors", r.tags, 0.1)
|
||||
|
||||
// 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)
|
||||
if jerr != nil {
|
||||
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
|
||||
}
|
||||
|
||||
parser := rac.pool.Get()
|
||||
defer rac.pool.Put(parser)
|
||||
|
||||
val, err := parser.ParseBytes(bb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue