From 6f5107d76ad1c1fe5762405284773019f674ba01 Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Mon, 27 Nov 2023 16:51:33 +0000 Subject: [PATCH 1/2] refactor: upgrade to axum 0.7 --- examples/axum_example/api/Cargo.toml | 16 ++++++++-------- examples/axum_example/service/Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/axum_example/api/Cargo.toml b/examples/axum_example/api/Cargo.toml index de7462e48..248c5035f 100644 --- a/examples/axum_example/api/Cargo.toml +++ b/examples/axum_example/api/Cargo.toml @@ -7,16 +7,16 @@ publish = false [dependencies] axum-example-service = { path = "../service" } -tokio = { version = "1.29.0", features = ["full"] } -axum = "0.6.19" +tokio = { version = "1.34.0", features = ["full"] } +axum = "0.7.1" tower = "0.4.13" -tower-http = { version = "0.4.3", features = ["fs"] } +tower-http = { version = "0.5.0", features = ["fs"] } tower-cookies = "0.9.0" -anyhow = "1.0.71" +anyhow = "1.0.75" dotenvy = "0.15.7" -serde = "1.0.175" -serde_json = "1.0.102" -tera = "1.17.1" -tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } +serde = "1.0.193" +serde_json = "1.0.108" +tera = "1.19.1" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } entity = { path = "../entity" } migration = { path = "../migration" } diff --git a/examples/axum_example/service/Cargo.toml b/examples/axum_example/service/Cargo.toml index 0069d8d76..261b451b8 100644 --- a/examples/axum_example/service/Cargo.toml +++ b/examples/axum_example/service/Cargo.toml @@ -20,7 +20,7 @@ features = [ ] [dev-dependencies] -tokio = { version = "1.20.0", features = ["macros", "rt"] } +tokio = { version = "1.34.0", features = ["macros", "rt"] } [features] mock = ["sea-orm/mock"] From acada8e11c2d5a8186b58ad51f99ea7950a1d32d Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Mon, 27 Nov 2023 16:58:10 +0000 Subject: [PATCH 2/2] refactor: upgrade to axum 0.7 --- examples/axum_example/api/Cargo.toml | 2 +- examples/axum_example/api/src/lib.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/axum_example/api/Cargo.toml b/examples/axum_example/api/Cargo.toml index 248c5035f..bc82d122b 100644 --- a/examples/axum_example/api/Cargo.toml +++ b/examples/axum_example/api/Cargo.toml @@ -11,7 +11,7 @@ tokio = { version = "1.34.0", features = ["full"] } axum = "0.7.1" tower = "0.4.13" tower-http = { version = "0.5.0", features = ["fs"] } -tower-cookies = "0.9.0" +tower-cookies = "0.10.0" anyhow = "1.0.75" dotenvy = "0.15.7" serde = "1.0.193" diff --git a/examples/axum_example/api/src/lib.rs b/examples/axum_example/api/src/lib.rs index 28a7572b9..4cf8d80e5 100644 --- a/examples/axum_example/api/src/lib.rs +++ b/examples/axum_example/api/src/lib.rs @@ -5,7 +5,7 @@ use axum::{ http::StatusCode, response::Html, routing::{get, get_service, post}, - Router, Server, + Router, }; use axum_example_service::{ sea_orm::{Database, DatabaseConnection}, @@ -15,8 +15,7 @@ use entity::post; use flash::{get_flash_cookie, post_response, PostResponse}; use migration::{Migrator, MigratorTrait}; use serde::{Deserialize, Serialize}; -use std::str::FromStr; -use std::{env, net::SocketAddr}; +use std::env; use tera::Tera; use tower_cookies::{CookieManagerLayer, Cookies}; use tower_http::services::ServeDir; @@ -63,8 +62,8 @@ async fn start() -> anyhow::Result<()> { .layer(CookieManagerLayer::new()) .with_state(state); - let addr = SocketAddr::from_str(&server_url).unwrap(); - Server::bind(&addr).serve(app.into_make_service()).await?; + let listener = tokio::net::TcpListener::bind(&server_url).await.unwrap(); + axum::serve(listener, app).await?; Ok(()) }