diff --git a/Cargo.toml b/Cargo.toml index 634e069b..b695086c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,4 @@ [workspace] members = ["telers", "telers-*", "examples/*"] default-members = ["telers", "telers-*"] -exclude = [] resolver = "2" diff --git a/examples/axum_and_echo_bot/Cargo.toml b/examples/axum_and_echo_bot/Cargo.toml index 099cee08..2fe49a2b 100644 --- a/examples/axum_and_echo_bot/Cargo.toml +++ b/examples/axum_and_echo_bot/Cargo.toml @@ -8,4 +8,4 @@ telers = { path = "../../telers", features = ["default"] } tokio = { version = "1.28", features = ["macros", "rt-multi-thread"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -axum = "0.6" \ No newline at end of file +axum = "0.7" \ No newline at end of file diff --git a/examples/axum_and_echo_bot/src/main.rs b/examples/axum_and_echo_bot/src/main.rs index bd972edc..52b29115 100644 --- a/examples/axum_and_echo_bot/src/main.rs +++ b/examples/axum_and_echo_bot/src/main.rs @@ -5,7 +5,7 @@ //! RUST_LOG={log_level} BOT_TOKEN={your_bot_token} cargo run --package axum_and_echo_bot //! ``` -use axum::{routing::get, Router as AxumRouter, Server}; +use axum::{routing, Router as AxumRouter}; use telers::{ enums::UpdateType, event::{telegram::HandlerResult, EventReturn, ToServiceProvider as _}, @@ -13,6 +13,7 @@ use telers::{ types::Message, Bot, Dispatcher, Router as TelersRouter, }; +use tokio::net::TcpListener; use tracing::{event, Level}; use tracing_subscriber::{fmt, layer::SubscriberExt as _, util::SubscriberInitExt as _, EnvFilter}; @@ -57,11 +58,11 @@ async fn main() { .unwrap(); let app = AxumRouter::new() - .route("/", get(hello_world_handler)) + .route("/", routing::get(hello_world_handler)) .into_make_service(); - let server = Server::bind(&"0.0.0.0:3000".parse().unwrap()); - + // `tokio::spawn` is used to run polling and server in different threads. + // You can also don't use `tokio::spawn` and run them in the same thread. tokio::join!( async { match tokio::spawn(dispatcher.run_polling()).await { @@ -78,7 +79,13 @@ async fn main() { // Check graceful shutdown example of axum server: // https://github.com/tokio-rs/axum/tree/main/examples/graceful-shutdown // Telers provides graceful shutdown out of the box, so you don't need to do anything special. - match tokio::spawn(server.serve(app)).await { + match tokio::spawn(async { + let listener = TcpListener::bind("0.0.0.0:3000").await?; + + axum::serve(listener, app).await + }) + .await + { Ok(Ok(())) => {} Ok(Err(err)) => { event!(Level::ERROR, "Error in server: {:?}", err); diff --git a/telers/Cargo.toml b/telers/Cargo.toml index 13fa6f28..a05c5601 100644 --- a/telers/Cargo.toml +++ b/telers/Cargo.toml @@ -27,9 +27,9 @@ tokio-util = { version = "0.7", features = ["codec"] } reqwest = { version = "0.11", features = ["multipart", "stream"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_with = "3.4" -strum = "0.25" -strum_macros = "0.25" +serde_with = "3.6" +strum = "0.26" +strum_macros = "0.26" futures = "0.3" async-trait = "0.1" once_cell = "1.16"