upgrade to Axum 0.7 (#1984)

* refactor: upgrade to axum 0.7

* refactor: upgrade to axum 0.7
This commit is contained in:
ttys3 2023-11-28 02:28:49 +08:00 committed by GitHub
parent 09a1983a0a
commit 3ff4f11cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 15 deletions

View File

@ -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-cookies = "0.9.0"
anyhow = "1.0.71"
tower-http = { version = "0.5.0", features = ["fs"] }
tower-cookies = "0.10.0"
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" }

View File

@ -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(())
}

View File

@ -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"]