ArdanUltimateRust-5Days icon indicating copy to clipboard operation
ArdanUltimateRust-5Days copied to clipboard

Axum version needs to be pinned

Open clvx opened this issue 11 months ago • 0 comments

In the code/videos related to Axum, it's used 0.6.* but >0.7 has a breaking change..

cargo add axum -F multipart.

// Build Axum with an "extension" to hold the database connection pool
let app = Router::new()
    .route("/", get(test))
    .layer(Extension(pool));
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
axum::Server::bind(&addr)
    .serve(app.into_make_service())
    .await
    .unwrap();

to:

let app = Router::new()
    .route("/", get(test))
    .layer(Extension(pool));

    let listener = TcpListener::bind("127.0.0.1:3000").await?;
    axum::serve(listener, app).await?;

clvx avatar Jan 21 '25 22:01 clvx