Trying to compile
use actix_web::{get, App, HttpServer, Responder};
#[get("/{id}/{name}/index.html")]
async fn index(info: web::Path<(u32, String)>) -> impl Responder {
format!("Hello {}! id:{}", info.1, info.0)
}
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(index))
.bind("127.0.0.1:8080")?
.start()
.await
}
with rustc stable 1.39.x produces
error[E0433]: failed to resolve: could not find `main` in `actix_rt` --> src\main.rs:8:13 \| 8 \| #[actix_rt::main] \| ^^^^ could not find `main` in `actix_rt` error[E0433]: failed to resolve: use of undeclared type or module `web` --> src\main.rs:4:22 \| 4 \| async fn index(info: web::Path<(u32, String)>) -> impl Responder { \| ^^^ use of undeclared type or module `web` error[E0277]: the trait bound `actix_server::server::Server: std::future::Future` is not satisfied --> src\main.rs:10:5 \| 10 \| / HttpServer::new(\|\| App::new().service(index)) 11 \| \| .bind("127.0.0.1:8080")? 12 \| \| .start() 13 \| \| .await \| \|______________^ the trait `std::future::Future` is not implemented for `actix_server::server::Server` error[E0277]: `main` has invalid return type `impl std::future::Future` --> src\main.rs:9:20 \| 9 \| async fn main() -> std::io::Result<()> { \| ^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `std::process::Termination` \| = help: consider using `()`, or a `Result`
--
Because you need actix-web from master
You need to add the following to your Cargo.toml:
actix-rt = "1.0.0-alpha.1"
I couldn't get the example to compile with master.
actix-web = {git = "https://github.com/actix/actix-web.git", branch = "master"}
# Tried with and without actix_rt
actix-rt = "1.0.0-alpha.1"
actix-http is failing to compile with a boat load of errors, from I can see it's unresolved imports from actix_rt and trait bounds problems with h2
alpha.3 should work
Works with that :
[dependencies]
actix-web = "2.0.0-alpha.4"
actix-rt = "1.0.0-alpha.3"
PS : Need to use also 'web'
Most helpful comment
Works with that :
PS : Need to use also 'web'