This commit is contained in:
Temirkhan Myrzamadi 2020-03-30 18:58:57 +06:00
parent 6e486f0d78
commit f6647d5196
2 changed files with 10 additions and 5 deletions

View file

@ -47,7 +47,7 @@ serde_with_macros = "1.0.1"
teloxide-macros = "0.2.1"
warp = "0.2.2"
warp = { version = "0.2.2", features = ["tls"] }
[dev-dependencies]
smart-default = "0.6.0"

View file

@ -211,6 +211,8 @@ pub fn polling(
pub async fn webhook(
bot: Arc<Bot>,
addr: SocketAddr,
cert_path: &'static str,
key_path: &'static str,
url: Url,
certificate: Option<InputFile>,
max_connections: Option<i32>,
@ -226,15 +228,18 @@ pub async fn webhook(
let server = warp::post().and(warp::path(url)).and(warp::body::json()).map(
move |update: Update| {
tx.send(Ok(update.clone()))
.expect("Cannot send an update from webhook");
tx.send(Ok(update)).expect("Cannot send an update from webhook");
""
},
);
tokio::spawn(async move {
// TODO: Tls
warp::serve(server).run(addr).await;
warp::serve(server)
.tls()
.cert_path(cert_path)
.key_path(key_path)
.run(addr)
.await;
});
Ok(rx)