From b6575a2934b018fc5109ac4b161cc52f51210436 Mon Sep 17 00:00:00 2001 From: Dmitriy Kharchenko <43345312+dmitriy-kharchenko@users.noreply.github.com> Date: Wed, 29 Jul 2020 09:51:11 +0300 Subject: [PATCH] Added stream processing of input JSON Co-authored-by: TJ Horner --- bot.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/bot.go b/bot.go index 5a13ec7..16cdacd 100644 --- a/bot.go +++ b/bot.go @@ -579,17 +579,8 @@ func (bot *BotAPI) HandleUpdate(r *http.Request) (*Update, error) { return nil, err } - payload, err := ioutil.ReadAll(r.Body) - if err != nil { - return nil, err - } - - if err := r.Body.Close(); err != nil { - return nil, err - } - var update Update - err = json.Unmarshal(payload, &update) + err := json.NewDecoder(r.Body).Decode(&update) if err != nil { return nil, err }