Skip to content

use tokio and actix-web together #3025

Answered by Darksonn
luxl asked this question in Q&A
Oct 22, 2020 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Tokio 0.2 and 0.3 are not directly compatible, but there is a compatibility layer available, which is described in the Compatibility between 0.2 and 0.3 section of the 0.3 announcement.

Assuming HttpServer requires Tokio 0.2, you can use it like this:

use tokio_compat_02::FutureExt;

start_server().compat().await;
async fn start_server() {
    HttpServer::new(move || {
        App::new()
            .configure(pet_routes)
    }).bind("0.0.0.0:41310")?.run().await
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by luxl
Comment options

You must be logged in to vote
2 replies
@davidbarsky
Comment options

@Darksonn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants