Added stream processing of input JSON Co-authored-by: TJ Horner <me@tjhorner.com>
Dmitriy Kharchenko 43345312+dmitriy-kharchenko@users.noreply.github.com
Wed, 29 Jul 2020 09:51:11 +0300
1 files changed,
1 insertions(+),
10 deletions(-)
jump to
M
bot.go
→
bot.go
@@ -579,17 +579,8 @@ err := errors.New("wrong HTTP method required POST")
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 }