From 183486a04490d1904117ba2e16c96401a81e7abf Mon Sep 17 00:00:00 2001 From: Waffle Date: Tue, 6 Jul 2021 15:10:22 +0300 Subject: [PATCH] Update heroku and ngrok examples --- examples/heroku_ping_pong_bot/src/main.rs | 4 ++-- examples/ngrok_ping_pong_bot/src/main.rs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/heroku_ping_pong_bot/src/main.rs b/examples/heroku_ping_pong_bot/src/main.rs index 2043ec49..653fc9f8 100644 --- a/examples/heroku_ping_pong_bot/src/main.rs +++ b/examples/heroku_ping_pong_bot/src/main.rs @@ -8,7 +8,7 @@ use tokio::sync::mpsc; use tokio_stream::wrappers::UnboundedReceiverStream; use warp::Filter; -use reqwest::StatusCode; +use reqwest::{StatusCode, Url}; #[tokio::main] async fn main() { @@ -30,7 +30,7 @@ pub async fn webhook(bot: AutoSend) -> impl update_listeners::UpdateListene // Heroku host example .: "heroku-ping-pong-bot.herokuapp.com" let host = env::var("HOST").expect("have HOST env variable"); let path = format!("bot{}", teloxide_token); - let url = format!("https://{}/{}", host, path); + let url = Url::parse(&format!("https://{}/{}", host, path)).unwrap(); bot.set_webhook(url).await.expect("Cannot setup a webhook"); diff --git a/examples/ngrok_ping_pong_bot/src/main.rs b/examples/ngrok_ping_pong_bot/src/main.rs index 8a35d5ad..c748e0c8 100644 --- a/examples/ngrok_ping_pong_bot/src/main.rs +++ b/examples/ngrok_ping_pong_bot/src/main.rs @@ -8,7 +8,7 @@ use tokio::sync::mpsc; use tokio_stream::wrappers::UnboundedReceiverStream; use warp::Filter; -use reqwest::StatusCode; +use reqwest::{StatusCode, Url}; #[tokio::main] async fn main() { @@ -21,9 +21,11 @@ async fn handle_rejection(error: warp::Rejection) -> Result) -> impl update_listeners::UpdateListener { + let url = Url::parse("Your HTTPS ngrok URL here. Get it by `ngrok http 80`").unwrap(); + // You might want to specify a self-signed certificate via .certificate // method on SetWebhook. - bot.set_webhook("Your HTTPS ngrok URL here. Get it by `ngrok http 80`") + bot.set_webhook(url) .await .expect("Cannot setup a webhook");