1
0
Fork 0

🏗️ Use fasthttp.URI in NewWebhookChannel parameters

This commit is contained in:
Maxim Lebedev 2018-10-09 15:54:45 +05:00
parent 5c0b154c70
commit 9ed9e1d2d1
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
1 changed files with 2 additions and 5 deletions

View File

@ -3,7 +3,6 @@ package telegram
import (
"bytes"
"log"
"net/url"
"time"
"github.com/kirillDanshin/dlog"
@ -50,7 +49,7 @@ func (b *Bot) NewLongPollingChannel(params *GetUpdatesParameters) UpdatesChannel
// NewWebhookChannel creates channel for receive incoming updates via an outgoing
// webhook.
func (b *Bot) NewWebhookChannel(setURL *url.URL, params *SetWebhookParameters, certFile, keyFile, serveAddr string) (updates UpdatesChannel) {
func (b *Bot) NewWebhookChannel(setURL *http.URI, params *SetWebhookParameters, certFile, keyFile, serveAddr string) (updates UpdatesChannel) {
if params == nil {
params = &SetWebhookParameters{
URL: setURL.String(),
@ -60,11 +59,9 @@ func (b *Bot) NewWebhookChannel(setURL *url.URL, params *SetWebhookParameters, c
var err error
channel := make(chan Update, 100)
requiredPath := []byte(setURL.Path)
dlog.Ln("requiredPath:", string(requiredPath))
handleFunc := func(ctx *http.RequestCtx) {
dlog.Ln("Request path:", string(ctx.Path()))
if !bytes.HasPrefix(ctx.Path(), requiredPath) {
if !bytes.HasPrefix(ctx.Path(), setURL.Path()) {
dlog.Ln("Unsupported request path:", string(ctx.Path()))
return
}