From e6191af6795c37f1757d8ddba638ebb88e86c30b Mon Sep 17 00:00:00 2001 From: zhuharev Date: Tue, 7 Nov 2017 05:17:06 +0300 Subject: [PATCH] add doc message --- bot.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/bot.go b/bot.go index 7d94a2c..41e9b27 100644 --- a/bot.go +++ b/bot.go @@ -78,14 +78,6 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, log.Printf("%s resp: %s", endpoint, bytes) } - if resp.StatusCode == http.StatusForbidden { - return APIResponse{}, errors.New(ErrAPIForbidden) - } - - if resp.StatusCode != http.StatusOK { - return APIResponse{}, errors.New(http.StatusText(resp.StatusCode)) - } - if !apiResp.Ok { return apiResp, errors.New(apiResp.Description) } @@ -93,6 +85,9 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, return apiResp, nil } +// decodeAPIResponse decode response and return slice of bytes if debug enabled. +// If debug disabled, just decode http.Response.Body stream to APIResponse struct +// for efficient memory usage func (bot *BotAPI) decodeAPIResponse(responseBody io.Reader, resp *APIResponse) (_ []byte, err error) { if !bot.Debug { dec := json.NewDecoder(responseBody)