1
0
mirror of https://github.com/actix/examples synced 2025-06-26 09:17:41 +02:00

upgrade to 2.0 alpha.3

This commit is contained in:
Nikolay Kim
2019-12-07 23:59:24 +06:00
parent e7f7175b7b
commit 3127352797
100 changed files with 1075 additions and 1107 deletions

View File

@ -1,12 +1,11 @@
[package]
name = "unix-socket"
version = "0.1.0"
version = "1.0.0"
authors = ["Messense Lv <messense@icloud.com>"]
workspace = ".."
edition = "2018"
[dependencies]
env_logger = "0.5"
tokio-uds = "0.2"
actix-web = { version = "1.0.5", features = ["uds"] }
env_logger = "0.6"
actix-web = "2.0.0-alpha.3"
actix-rt = "1.0.0-alpha.3"

View File

@ -1,10 +1,12 @@
use actix_web::{middleware, web, App, HttpRequest, HttpServer};
fn index(_req: HttpRequest) -> &'static str {
async fn index(_req: HttpRequest) -> &'static str {
"Hello world!"
}
fn main() -> std::io::Result<()> {
#[actix_rt::main]
#[cfg(unix)]
async fn main() -> std::io::Result<()> {
::std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
env_logger::init();
@ -13,10 +15,18 @@ fn main() -> std::io::Result<()> {
// enable logger - always register actix-web Logger middleware last
.wrap(middleware::Logger::default())
.service(
web::resource("/index.html").route(web::get().to(|| "Hello world!")),
web::resource("/index.html")
.route(web::get().to(|| async { "Hello world!" })),
)
.service(web::resource("/").to(index))
})
.bind_uds("/tmp/actix-uds.socket")?
.run()
.start()
.await
}
#[cfg(not(unix))]
fn main() -> std::io::Result<()> {
println!("not supported");
Ok(())
}