Close hanging channel in ListenForWebhookRespReqFormat

bot-api-6.1
Fabio Massaioli 2022-04-24 03:35:19 +02:00 committed by GitHub
parent 537c005643
commit 2e8be8df9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

3
bot.go
View File

@ -494,6 +494,8 @@ func (bot *BotAPI) ListenForWebhookRespReqFormat(w http.ResponseWriter, r *http.
ch := make(chan Update, bot.Buffer) ch := make(chan Update, bot.Buffer)
func(w http.ResponseWriter, r *http.Request) { func(w http.ResponseWriter, r *http.Request) {
defer close(ch)
update, err := bot.HandleUpdate(r) update, err := bot.HandleUpdate(r)
if err != nil { if err != nil {
errMsg, _ := json.Marshal(map[string]string{"error": err.Error()}) errMsg, _ := json.Marshal(map[string]string{"error": err.Error()})
@ -504,7 +506,6 @@ func (bot *BotAPI) ListenForWebhookRespReqFormat(w http.ResponseWriter, r *http.
} }
ch <- *update ch <- *update
close(ch)
}(w, r) }(w, r)
return ch return ch