1
0
mirror of https://github.com/actix/examples synced 2025-06-28 18:00:37 +02:00

update docker sample

This commit is contained in:
Rob Ede
2022-01-27 02:58:13 +00:00
parent 6e34f07fbf
commit d327e8800b
5 changed files with 887 additions and 1090 deletions

View File

@ -1,26 +1,28 @@
#[macro_use]
extern crate actix_web;
use actix_web::{App, HttpResponse, HttpServer, Responder};
use actix_web::{get, middleware::Logger, App, HttpResponse, HttpServer, Responder};
#[get("/")]
async fn index() -> impl Responder {
println!("GET: /");
HttpResponse::Ok().body("Hello world!")
}
#[get("/again")]
async fn again() -> impl Responder {
println!("GET: /again");
HttpResponse::Ok().body("Hello world again!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
println!("Starting actix-web server");
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
HttpServer::new(|| App::new().service(index).service(again))
.bind("0.0.0.0:5000")?
.run()
.await
log::info!("Starting HTTP server: go to http://localhost:8080");
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
.service(index)
.service(again)
})
.bind(("0.0.0.0", 8080))?
.run()
.await
}