pull/73/merge
Dmitry V. Roenko 9 years ago committed by GitHub
commit 9e398ec598
  1. 14
      bot.go

@ -482,9 +482,19 @@ func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (updatesChannel, error) {
return ch, nil return ch, nil
} }
// ListenForWebhook registers a http handler for a webhook. // ListenForWebhook registers a http handler for a webhook with custom buffer size.
// Beware: larger values will increase memory consumption.
func (bot *BotAPI) ListenForWebhookWithBufferSize(pattern string, bufferSize int) updatesChannel {
return listenForWebhookWithBufferSize(pattern, bufferSize)
}
// ListenForWebhook registers a http handler for a webhook, with buffer size set to default value - 100.
func (bot *BotAPI) ListenForWebhook(pattern string) updatesChannel { func (bot *BotAPI) ListenForWebhook(pattern string) updatesChannel {
ch := make(chan Update, 100) return listenForWebhookWithBufferSize(pattern, 100)
}
func listenForWebhookWithBufferSize(pattern string, bufferSize int) updatesChannel {
ch := make(chan Update, bufferSize)
http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) { http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
bytes, _ := ioutil.ReadAll(r.Body) bytes, _ := ioutil.ReadAll(r.Body)