3 ms·
cargo new example-server cd ./example-server cargo add actix-web (quickly searches crates.io for `actix-web`) Cool, copy and paste: use actix_web::{get
by insanitybit 4y ago
cargo new example-server
cd ./example-server
cargo add actix-web
(quickly searches crates.io for `actix-web`)
Cool, copy and paste:
use actix_web::{get, web, App, HttpServer, Responder};
#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
format!("Hello {name}!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(greet)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
takes ~a minute. Not sure std would have saved me any time, I would have just searched the stdlib docs instead of crates.io for actix. And I guess I wouldn't need to `cargo add actix-web` lol that was not the bottleneck.
- giancarlostoro 4y agoHow does a Rust beginner know what actix-web even is though? In Go the net/http library is discussed early on when learning Go.